Is there a way to create a color bar that is positioned halfway below the title using only CSS? I am looking to only color the lower half of a div - can this be achieved

Is there a way to create a color bar beneath the title using only HTML and CSS without relying on background images? I want the bar to be flush with the text and have some flexibility in terms of width to prevent wrapping.

Alternatively, can you position an image at the bottom with specified left and right margins only for the background image to allow better control over its positioning?

.title_container{
  top: 10px;
  left:10px;
  width: 500px;
  height: 200px;
  color: #fff;
  background-color: #437199;
  position: relative;
  text-align: center;
  padding-top: 20px;  
}

.title{
    margin: 0px 20px;
    height: 40px;
    background-image: url("https://i.sstatic.net/zJqH5.png");
    background-position: bottom;
    background-repeat: repeat-x;
}

.title_sub_text{
    padding-top: 10px;
    font-weight: bold;
    overflow: hidden;
    position: relative;
}
h1{
    top:10px;
    /* position: absolute; */
}

button, button:hover, button:active, button:focus{
    width: 210px;
    height: 46px;
    color:#fff;
    font-weight: bold;
    text-decoration: none;
    background-color: #967e2c;
    border-bottom: 4px solid #f1ba43;
    padding-top: 4px;
    margin: 20px 0px;
    border-style: solid;
}
button:active {

    border-style: solid;
}

Answer №1

Wowza

.title_container{
  top: 10px;
  left:10px;
  width: 500px;
  height: 200px;
  color: #fff;
  background-color: #437199;
  position: relative;
  text-align: center;
  padding-top: 20px;  
}

.title{
    margin: 0px 20px;
    height: 40px;
 /*    border-bottom:15px solid navy;    */
   background:
    linear-gradient(#437199,#437199) 0 calc(-1px)/100% 22px no-repeat,
    navy;
}



.title_sub_text{
    padding-top: 10px;
    font-weight: bold;
    overflow: hidden;
    position: relative;
}
h1{
    top:10px;
    /* position: absolute; */
}

button, button:hover, button:active, button:focus{
    width: 210px;
    height: 46px;
    color:#fff;
    font-weight: bold;
    text-decoration: none;
    background-color: #967e2c;
    border-bottom: 4px solid #f1ba43;
    padding-top: 4px;
    margin: 20px 0px;
    border-style: solid;
}
button:active {

    border-style: solid;
}
<div class="title_container"> 
<div class="title"><h1>Lorum Ipsum Lorum Ipsu Title</h1></div>
<div class="title_sub_text">Bacon Ipsum Bacon Ipsum Bacon Subtitle</div>
<button type="button">Call To Action</button>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Whenever I attempt to use window.print(), the styling gets completely messed up. I've experimented with both @media screen and @media print, but unfortunately, I

I am working on creating an invoice, the design looks perfect in the browser, but when I try to window.print() the style gets corrupted. I attempted to include @media screen and @media print, but I am still facing the same issue. The invoice form is incorp ...

How to use plain JavaScript to extract the value from a textarea in GWT

Situation: I am currently developing a tampermonkey script to enhance certain GWT pages within a third-party application. Unfortunately, I do not have access to the source code or servers. Challenge: My task is to retrieve the value of a textarea element ...

Unable to access placeholder information from the controller

I am new to implementing the mean stack. I attempted to view data from the controller, but encountered an error message in the web browser's console. Error: [$controller:ctrlreg] http://errors.angularjs.org/1.6.3/$controller/ctrlreg?p0=AppCtrl Stack ...

I prefer to have the links activate when the mouse hovers over them, rather than when hovering over empty

Is there a way to prevent the bottom links (music, contact, archive) from being highlighted when the mouse hovers over the empty space between them and not just on the actual links themselves? I want the mouse to only react to the links it hovers over and ...

Newbie inquiries regarding the process of migrating a CRUD application to PhalconPHP

I have recently delved into using PhalconPHP 1.3.1 for an application related to my master's thesis. While it is still a work in progress, I am currently focusing on implementing CRUD functionality and refining the user interface. This endeavor marks ...

Steps to modify the background color of Bootstrap custom-file-input classes

I am struggling with changing the background color of my input[type="file"]. Despite researching similar issues, none of the solutions I found helped resolve my problem. I am hopeful that someone here can provide some assistance. Below is the snippet from ...

PHP: Bootstrap CSS for Carousels

I'm experiencing some difficulties with the Bootstrap CSS Carousel on my website. The left and right arrows seem to be unresponsive, and the slides are not transitioning automatically. I have been unable to identify the root cause of this issue. Belo ...

Having trouble retrieving a base64 encoded image from a MySQL database using PHP

Within my MySQL database, there is a longblob field that stores a binary value representing an image uploaded through my website. I am currently attempting to retrieve the image using: <?php while($record = mysqli_fetch_assoc($result)): ?> <div&g ...

I'm curious if there is a specific jQuery event that triggers right before an element loses focus or right before the next element gains focus

I am facing a situation where I have two input elements in a form that are closely connected. The first element triggers an ajax call to check for existing data in the database when the user tries to move away from it, while the second element opens a moda ...

Tips for adding a gradient to your design instead of a plain solid color

I stumbled upon a snippet on CSS Tricks Attempting to replace the green color with a gradient value, but unfortunately, the value is not being applied. I have tried using both the fill property and gradient color, but neither has been successful. Here is ...

What is the best method for developing a live text display switcher that works across different pages?

Hello everyone! I am currently in the process of creating a display toggler for my website. I have two separate pages, index.html and toggler.html. In index.html, the "TEXT" is displayed, while toggler.html contains the actual toggler or switch button. Whe ...

Utilize an A-frame conditional statement to check a variable and dynamically display various glTF models depending on its value

Is it possible to use JavaScript and A-frame () to create a scenario like this? I want to have an onload function named load() that will evaluate the value of variable x. If x is equal to one, I want the gltf with the ID of 1 to be visible while hiding th ...

Uploading an HTML file website on Heroku deployment platform

I recently created a small website using HTML, CSS, Bootstrap, and JavaScript files. The main page is named index.html. However, I encountered an issue when trying to deploy it to my Heroku app (with the Node.js buildpack) as it kept showing an error messa ...

Tips for managing callbacks from a RESTful service API on IOS

Utilizing an API to enable users to register an account on my application. Currently, I have managed to craft the necessary URL in objective-C to submit the data, with the API documentation detailing the return codes that will indicate the outcome. My qu ...

Potential issue: Firefox causes distortion in animated stroke-linecap="round" properties

While working on a project on Stack Overflow, I noticed a potential bug in Firefox when animating a line with stroke-linecap="round" and vector-effect="non-scaling-stroke" svg{border:1px solid} path{ animation: draw 1s ease-in; ...

Tips on personalizing the checkbox by incorporating a custom background image

Looking to spruce up the standard checkbox? We're open to any method - whether it's a background image, CSS3, or some jQuery magic. Check out this example for inspiration! ...

Creating a Welcome Page for my React Application with IndexRoute

I am in the process of setting up a landing page that will then redirect to my main home page using React. I have created a component for the landing page named Splash. I am attempting to utilize IndexRoute to make sure my app initially displays Splash as ...

What is the sequence in which jQuery events are triggered?

In my HTML code, I have the following: <a href="#" class="topHierarchy big-link" data-reveal-id="myModal" > Both classes, "topHierarchy" and "big-link", are used to attach jQuery event handlers (onClick). big-link triggers a popup box to show, whi ...

Using Django Template Variables in JavaScript Functions

Within one of my templates, there is a for loop that iterates over all the items. Whenever a user likes or dislikes an item, it should trigger a function in my code. I successfully set up the button's HTML like this: <button onclick='update_li ...

display a tooltip for a disabled image hyperlink in JSP

I am currently working on a popup menu that displays different images, each with its own unique link. Here is an example of what a single menu element looks like: <li class="button-link" data-idp="idfirst"> <s:a href='%{l ...