Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7805857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:20:45+00:00 2026-06-02T02:20:45+00:00

I have this css: <style type=text/css> .chart { position: relative; width:300px; height:85px; padding:0; margin:0;

  • 0

I have this css:

<style type="text/css">

    .chart {
        position: relative;
        width:300px;
        height:85px;
        padding:0;
        margin:0;       
        background:url("prova2.png") center bottom no-repeat;
        z-index:1;
    }

    .chart div{     
        float:left;
        font-size:13px;
        text-align:center;
    }

    .chart .green{
        position:absolute;
        left: 50px;
        top:50px;
        height:35px;
        width:50px;
        background: green;
    }

</style>

and this html code:

<div class="chart">

    <div style="margin-left:15px;">
        <b>-2</b><br />
        0.1234
    </div>  
    <div style="margin-left:27px;">
        <b>-1</b><br />
        0.1234
    </div>  
    <div style="margin-left:27px;">
        <b>MEDIA</b><br />
        0.1234
    </div>  
    <div style="margin-left:18px;">
        <b>+1</b><br />
        0.1234
    </div>  
    <div style="margin-left:27px;">
        <b>+2</b><br />
        0.1234
    </div>  

    <div class="green"></div>   

</div>

as you can see I use prova2.png that has transparencies.

This is the image:

enter image description here

The result of the code is:

enter image description here

has you can see the green rectangle is ABOVE the image, BUT i really do not understand the reason, because i used the z-index and the div (with the image as background) has z-index:1, so…

Why green div IS above?

I need to set dinamically a color as background, BUT I must the see the vertical lines (of the .png image….the rest of the image is transparent), so the lines ABOVE the green div, and the GREEN in the transparent parts.

Could someone help me?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:20:46+00:00Added an answer on June 2, 2026 at 2:20 am

    By using z-index you determine not only the stack level of the current, but also of its child elements. See the z-index specification:

    Within each stacking context, the following layers are painted in back-to-front order:

    1. the background and borders of the element forming the stacking context.
    2. the child stacking contexts with negative stack levels (most negative first).
    3. the in-flow, non-inline-level, non-positioned descendants.
    4. the non-positioned floats.
    5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks.
    6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
    7. the child stacking contexts with positive stack levels (least positive first).

    EDIT: A very simple way to fix this issue is to create a new <div> and place your image there:

    <div class="chart">
        <!-- other divs -->
        <div class="green"></div>
        <div class="chartmap"></div>
    </div>
    
    .chart {
        position: relative;
        width:300px;
        height:85px;
        padding:0;
        margin:0;
        z-index:1;
    }
    
    .chart div{
        /* same as above */
    }
    
    .chart .green{
        /* same as above */
    }
    
    .chart .chartmap{
        position: absolute; float:none;
        top: 0; left: 0; right: 0; bottom: 0;
        margin: 0; padding: 0; border: 0 none;
    
        background:url("prova2.png") center bottom no-repeat;
        z-index:1;
    }
    

    This time z-index will work since all elements share the same stacking context. Another possible solution is to use a real <img> and use a negative z-index on your <divs>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this css: <style type=text/css> #heading{ margin:auto; background-color: brown; } </style> and
I have this code <html> <head> <style type=text/css> .frame {width: 50em; border: 1px solid
I have a Div layer like this ... <style type=text/css> <!-- #newImg { position:absolute;
I have this CSS code: <style> body { position:absolute; background-image: url(art/c11.jpg); width:100%; height:100%; }
I have this: <html> <head> <title></title> <meta http-equiv='Content-Type' content='text/html; charset=utf8'> <style type='text/css'> body {
This is my css content :- <style type = text/css> li { display:inline; }
I have this code style.css .row { position: fixed; top: 0; left: 0; bottom:
I have created css page called style.php and included this the top: <?php header(Content-type:
I have this CSS style that does a rounded corners for div border, but
I have this in my CSS file: body {style.css (line 3) background:#CDF8FF url(images/final_bg.jpg) no-repeat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.