Having trouble setting the background of a div in CSS

How can I apply the background-color: #f8f8f8 class to the step class without interfering with the display of the horizontal lines after 1, 2? What could be causing this issue?

.main-progress {
    text-align: center;
    position: relative;
    margin-top: 30px;
}

.step{
 
}

/*progressbar*/
#progressbar {
    margin-bottom: 30px;
    overflow: hidden;
    /*CSS counters to number the steps*/
    counter-reset: step;
}

#progressbar li {
    list-style-type: none;
    color: #12bd2a;
    font-size: 14px;
    width: 33.33%;
    float: left;
    position: relative;
    font-weight: 600;
}

#progressbar .not-active:before {
    color: #ffffff;
    background: #4650ec;
}

#progressbar li:last-child{
  color: #4650ec;
}

#progressbar li:before {
    content: counter(step);
    counter-increment: step;
    width: 36px;
    height: 36px;
    line-height: 36px;
    display: block;
    font-size: 16px;
    color: #ffffff;
     background-color: #12bd2a;
    border-radius: 25px;
    margin: 0 auto 10px auto;
}

/*progressbar connectors*/
#progressbar li:after {
    content: '';
    width: 100%;
    height: 5px;
    background: black;
    position: absolute;
    left: -50%;
    top: 16px;
    z-index: -1; /*put it behind the numbers*/
}

#progressbar li:first-child:after {
    /*connector not needed before the first step*/
    content: none;
}

/*marking active/completed steps green*/
/*The number of the step and the connector before it = green*/
#progressbar li.active:before, #progressbar li.active:after {
    /*background-color: #12bd2a;*/
    color: white;
}
  <section class="step">
    <div class="container">
      <div class="row">
        <div class="col-12>
          <div class="main-progress">
            <ul id="progressbar">
              <li class="active">Upload Photos</li>
              <li class="active">Model Settings</li>
              <li class="not-active">Get Photos</li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </section>

Answer №1

give this code a shot

styling with css

    .main-progress {
    text-align: center;
    position: relative;
    margin-top: 30px;
    z-index:9;
}


.step{
 background-color: #f8f8f8;
}

/*progressbar*/
#progressbar {
    margin-bottom: 30px;
    overflow: hidden;
    /*Using CSS counters to number the steps*/
    counter-reset: step;
}

#progressbar li {
    list-style-type: none;
    color: #12bd2a;
    font-size: 14px;
    width: 33.33%;
    float: left;
    position: relative;
    font-weight: 600;
}

#progressbar .not-active:before {
    color: #ffffff;
    background: #4650ec;
}

#progressbar li:last-child{
  color: #4650ec;
}

#progressbar li:before {
    content: counter(step);
    counter-increment: step;
    width: 36px;
    height: 36px;
    line-height: 36px;
    display: block;
    font-size: 16px;
    color: #ffffff;
     background-color: #12bd2a;
    border-radius: 25px;
    margin: 0 auto 10px auto;
}

/*progressbar connectors*/
#progressbar li.active:after 
    content: '';
    width: 100%;
    height: 5px;
    background:black;
    position: absolute;
    left: -50%;
    top: 16px;
    z-index: -1; /*placed behind the numbers*/
}
#progressbar li.not-active:after {
    content: '';
    width: 100%;
    height: 5px;
    background: black;
    position: absolute;
    left: -50%;
    top: 16px;
    z-index: -1; /*placed behind the numbers*/
}

#progressbar li:first-child:after {
    /*no connector needed before the first step*/
    content: none;
}

/*highlighting active/completed steps in green*/
/*Step number and its connector = green*/
#progressbar li.active:before, #progressbar li.active:after {
    /*background-color: #12bd2a;*/
    color: white;
}

Answer №2

#progressbar:before,#progressbar:after{content:"";display:block;clear:both;}

Incorporate this code snippet to enable additional functionality. It guarantees seamless operation.

Answer №3

Your code had a minor issue with the z-index placement, where you placed it before the .step in the z-index layering. It would be beneficial to assign some z-index values to all the relevant elements.

.main-progress {
  text-align: center;
  position: relative;
  margin-top: 30px;
}

.step {
  background: grey;
  z-index: -1;
}


/*progressbar*/

#progressbar {
  margin-bottom: 30px;
  overflow: hidden;
  /*CSS counters to number the steps*/
  counter-reset: step;
}

#progressbar li {
  list-style-type: none;
  color: #12bd2a;
  font-size: 14px;
  width: 33.33%;
  float: left;
  position: relative;
  font-weight: 600;
}

#progressbar .not-active:before {
  color: #ffffff;
  background: #4650ec;
}

#progressbar li:last-child {
  color: #4650ec;
}

#progressbar li:before {
  content: counter(step);
  counter-increment: step;
  width: 36px;
  height: 36px;
  line-height: 36px;
  display: block;
  font-size: 16px;
  color: #ffffff;
  background-color: #12bd2a;
  border-radius: 25px;
  margin: 0 auto 10px auto;
}


/*progressbar connectors*/

#progressbar li:after {
  content: '';
  width: 100%;
  height: 5px;
  background: black;
  position: absolute;
  left: -50%;
  top: 16px;
  z-index: 1;
  /*put it behind the numbers*/
}

#progressbar li:first-child:after {
  /*connector not needed before the first step*/
  content: none;
}


/*marking active/completed steps green*/


/*The number of the step and the connector before it = green*/

#progressbar li.active:before,
#progressbar li.active:after {
  /*background-color: #12bd2a;*/
  color: white;
}
<section class="step">
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="main-progress">
          <ul id="progressbar">
            <li class="active">Upload Photos</li>
            <li class="active">Model Settings</li>
            <li class="not-active">Get Photos</li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</section>

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

Progressing through the Material UI LinearProgress bar in steps

How can I split a progress bar into more steps to achieve a design like this? https://i.stack.imgur.com/lRMj6.png I attempted using this code but couldn't find an option for splitting: <LinearProgress variant="determinate" classes={{ ...

Use jQuery to assign a unique CSS class to every third ul element on the page

Currently, I have a large number of li elements that I am iterating through and grouping in sets of 5. However, I need to assign a unique class to every third group in order to achieve the following structure: <ul class="class1"> ...

Adjusting the font color when hovering over multiline text

I am currently in the process of coding a website for my job, and I am working on changing the text color when it is hovered over. However, there seems to be a break in my code causing the text not to highlight all at once. Any guidance or suggestions on h ...

Having issues extracting information from easports.com due to difficulties with the <ea-elements-loader> element

Recently, I've been developing a Python WebScraper to extract data (such as wins and losses) from our FIFA ProClub by crawling various websites. While I successfully implemented it on a third-party website using BeautifulSoup and requests, I encounter ...

Save the $username and $file variables into the $_SESSION once the user logs in

Starting from index.php, I retrieve the values of the username and password fields using $_POST. index.php if(isset($_POST["username"]) && isset($_POST["password"])){ $username = mysql_real_escape_string(strtolower($_POST['username&apos ...

Dynamic scrolling text for overflowing text display

Here's a scenario I'm facing: Let's say I have three div tags, each 100 pixels wide: <--- DIV WIDTH ---> Text in div 1 Text in div two, it overflows Text in div three <--- DIV WIDTH ---> Currently, I've set the following C ...

Is there a way to set a default CSS background image using JavaScript in case the specified

When working with regular CSS, I can easily set a fallback image using this code in case the primary image is not available: .container { background-image: url(pics/img.webp), url(pics/img.png); } But when it comes to setting styles in JavaScript (such ...

Mastering Instagram Automation: Techniques for Navigating the Lightbox with Selenium

I am in the process of developing a Python script that assists users in Instagram engagement groups by efficiently liking everyone's photo during each round. I am facing an issue where Selenium is unable to click on the first photo when I reach a user ...

Using CSS3 to shift a div in relation to another moving div

Take a look at this JSfiddle. I am trying to make the "Push this!" div move when the menu resizes/expands on hover. Is it possible to achieve this effect using only CSS? <div id="nav"> <ul> <li><a href=""><span>01</spa ...

Modifying form data when submitting a form

Is there a common or widely-used method for modifying or adding form values before they are serialized and sent to the server upon form submission? I'm looking for a way to change or add these values without having to recreate them. I've come ac ...

When using the `position: absolute` and `left: 50%` properties on content with a `width: fit-content`, the content gets wrapped in Windows,

Why does the below code behave differently on Windows and Mac? On Windows, the content wraps or the div occupies only 50% of the browser's width, causing the content to wrap if its width exceeds 50% of the browser's width. However, on Mac, it tri ...

Embeddable javascript code can be enhanced by incorporating references into the header

I have developed a basic calculator application using HTML, JavaScript, JQuery, and CSS. My intention is to allow others to embed this calculator app on their own web pages by utilizing a file named generate.js. Within this file, there are several documen ...

Switch images when hovering

I currently have two dropdown menus called NEW and SHOP. When I hover over the New Menu 1, it should display the corresponding image. Similarly, when hovering over New Menu 2, the related image should be shown in a div with the ".menu-viewer" class. Whil ...

How can Angular be used for live search to provide precise search results even when the server does not return data in the expected sequence?

Currently, I am in the process of constructing a website for one of my clients. The search page on the site is designed to update search results as you type in the search bar - with each keystroke triggering a new search request. However, there's an i ...

What is the best way to show a pop-up message to a visitor on my site for the first time

I am seeking a way to showcase a popup the first time a user lands on my website. At present, the popup appears only upon page refresh. Check out the demo below: var popupdisplayed = false; jQuery(function() { jQuery('[data-popup-close]').o ...

Tips for refreshing the page without losing the values of variables

In my simulation.jsp file, I have the following code that retrieves simulation data from a struts2 action: $(document).ready(function() { var data='<s:property escape="false" value="simInfos" />'; } Once I perform the simulation with this ...

Personalize the color scheme for your timeline paper

I am interested in customizing this specific example of a personalized timeline: import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Timeline from '@material-ui/lab/Timeline'; import Timeli ...

The layout of my website appears distorted on mobile devices

When I view my website, http://www.healthot.com, on an iPhone or other mobile device, the page doesn't display correctly. It scales the window, requiring me to zoom out to see the entire page. To better understand the issue, please refer to this photo ...

Using blending modes with gradient colors in an SVG design

I'm struggling to get my logo to change colors upon scrolling into a button with similar gradient colors, but I just can't seem to make it work. Can anyone lend me a hand? Thank you! Take a look at my Logo. I've attempted to add some styles ...

The dynamic combination of jCarousel, jQuery Accordion, and fade in effects

Take a look at this link www.aboud-creative.com/demos/mckinley3. You'll find a jQuery Accordion with jCarousel inside the "Developments" section. I have implemented a standard fadeIn function for the logo, accordion, and a stag on the bottom right to ...