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

  • SEARCH
  • Home
  • 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 7954977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:35:38+00:00 2026-06-04T03:35:38+00:00

I am trying to put an absolutely positioned element under a relatively positioned one.

  • 0

I am trying to put an absolutely positioned element under a relatively positioned one. The blue box HAS to be relatively positioned due to constraints within the site development.

Imagine a speech bubble is the blue box, the bubble’s tail is the :after pseudo-element. I need the green box to go behind both of these as it is to hold a background for these two elements.

div.layer01 {
    background-color: blue;
    position: relative;
    z-index: 10;
}
div.layer01:after {  /* This is the tail of the bubble */
    display: block;
    background-color: red;
    content: '\00a0';
    width: 30px;
    height: 30px;
    position: absolute; 
    right: 20px;
    top: 50px;
    border: 3px #fff solid;
}    

/* This should be behind the tail and the blue box (bubble) */
div.layer01 div.layer02 { 
    background-color: green;
    width: 320px;
    height: 125px;
    display: block;
    position: absolute; 
    z-index: 5;
}
<div class="layer01"> <!-- speech bubble -->
    <div class="layer02">Why isn't this below the blue?</div>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus non dolor quis leo malesuada pharetra at in massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
</div>

FIX:

Took the element I wanted positioned out of the relatively positioned element then wrapped the contents into a new div. Adds mark up but seems this was the only way.

  • 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-04T03:35:40+00:00Added an answer on June 4, 2026 at 3:35 am

    Edit: I was misinformed, negative indexes were introduced in CSS2.1. This solution is still correct, though my comments about it being a hack are not.

    Child elements, even if absolutely positioned can’t be below their parent element unless you use a hack.

    The hack is to remove the z-index property from the parent and give the child element a negative z-index

    http://jsfiddle.net/uZdy3/1/

    div.layer01 {
        background-color: blue;
        position: relative;
    }
    div.layer01:after {  /* This is the tail of the bubble */
        display: block;
        background-color: red;
        content: '\00a0';
        width: 30px;
        height: 30px;
        position: absolute; 
        right: 20px;
        top: 50px;
        border: 3px #fff solid;
    }    
    
    /* This should be behind the tail and the blue box (bubble) */
    div.layer01 div.layer02 { 
        background-color: green;
        width: 320px;
        height: 125px;
        display: block;
        position: absolute; 
        z-index: -5;
    }
    

    It would be much better to refactor your layout to avoid this hack, though.

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

Sidebar

Related Questions

I am trying to animate an element that is absolutely positioned and positioned bottom
I'm trying to put two divs on the right side of parent div one
I'm trying to put a element to the left of a element, however I
I was trying to absolutely position an element at the bottom of the page
i am trying to put an html element -that i want to use to
Basically, I am trying to put overlap corners behind the #page_container on my site,
I'm trying put an if statement directly into a select field in rails, with
I trying to put together an Android app that will take a picture and
I'm trying to put together a fun 'contest' of sorts. Developers will write a
I am trying to put a filter on my C# openFileDialog that excludes certain

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.