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 7027335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:14:02+00:00 2026-05-28T00:14:02+00:00

I have two divs, both with 0.6 opacity. I need them to overlap but

  • 0

I have two divs, both with 0.6 opacity. I need them to overlap but retain their opacity and not create a new combined opacity level. I can’t use an image.

EDIT — The little circle is supposed to have a canvas element in it. Not sure if pseudo-elements would be the best solution.

Is there anyway to do this with CSS, or should I just use canvas?

example –

http://dabblet.com/gist/1566209

HTML:

<div id="foo">
    <div id="bar">
    </div>
</div>

CSS:

/**
 * Double Opacity
 */
body{background:green;}

#foo{
height:150px;
width:250px;
background:rgba(0, 0, 0, 0.6);
position:absolute;
left:40%;
top:20%;
}

#bar{
height:40px;
width:40px;
background:rgba(0, 0, 0, 0.6);
border-radius:40px;
position:absolute;
top:-15px;
left:-15px;
}
  • 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-05-28T00:14:03+00:00Added an answer on May 28, 2026 at 12:14 am

    SUMMARY:


    Depending on what is needed it can be tricky but the basic approach is pretty straight forward.


    This approach is a little different from my first thought… but this has the same result.

    1. I made a black/transparent pattern for the circle and set it to
      :before.
    2. The circle is then transformed rotate(180deg) and moved to fit on
      the corner of the <div>.
    3. Then I set the opacity of that circle to 0.6.
    4. The <div> itself is not affected by the opacity.
    5. Next I added the :after element and put an image as background
      (you can control this via js if needed)
    6. I added some effects to the image (border-radius, box-shadow,
      border) to show how easily and independent this element can be
      controlled.
    7. I used a lighter background and set the opacity to 0.3 to show
      the result

    HERE’S THE FIDDLE: http://jsfiddle.net/pixelass/nPjQh/4/

    Look at this version for some crazy results: http://jsfiddle.net/pixelass/nPjQh/5/

    each of these examples only use a single div element

    Basic rules. (these rules "could" be used to create a dynamic behavior with js)

    position = absolute;

    top = circleHeight / -2;

    left = circleHeight / -2; //(left = top)

    rotation = 180deg;

    opacity = valueAofBackground;

    bgColor = valueRGBofBackground;

    #inner {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        z-index: -1;
        background-color: rgba(0, 0, 0, 0.3);
        padding:20px;
        border-radius: 20px;
        border-top-left-radius: 0;
    }
    #inner:before {
        content: "";
        background-image: -webkit-linear-gradient(transparent 50%, rgb(0, 0, 0) 50%, rgb(0, 0, 0)),
            -webkit-linear-gradient(0deg, transparent 50%, rgb(0, 0, 0) 50%, rgb(0, 0, 0));
        height: 40px;
        width: 40px;
        border-radius: 40px;
        position: absolute;
        top: -20px;
        left: -20px;
        -webkit-transform: rotateZ(180deg);
        opacity:0.3;
    }
    #inner:after {
        content: "";
        background: url('http://lorempixel.com/10/10/sports/1/') no-repeat;
        background-position:0;
        height: 10px;
        width: 10px;
        border-radius: 10px;
        position: absolute;
        top: -6px;
        left: -6px;
        -webkit-box-shadow: 0 0 10px rgb(255,255,255);
        border: 1px rgb(255,255,255) solid;
    
    }
    

    Better explanaition


    Original commented version
    http://jsfiddle.net/pixelass/nPjQh/10/

    see the comments in the code below

    #inner {
    background: rgba(0,0,0,0.5) /*this is the full color-code of the div (with alpha)*/
    }
    #inner:before {
        /*the solid color of the circle = rgbValue of the div*/
        background-image: -webkit-linear-gradient(transparent 50%, rgb(0, 0, 0) 50%, rgb(0, 0, 0)),
            -webkit-linear-gradient(0deg, transparent 50%, rgb(0, 0, 0) 50%, rgb(0, 0, 0));
        /*opacity of the circle = alpha of the div*/
        opacity: 0.5;
    }
    

    This example has a full transparent div …the circle is a "pacman"- shape: http://jsfiddle.net/pixelass/nPjQh/14/

    pacman shaped circle


    Managing the offset of the circle


    Look at these examples that handle the offset of the circle (NOT USING PSEUDEO-ELEMENTS)

    1:1 copy of the OP’s code (15px offset): http://jsfiddle.net/pixelass/nPjQh/12/

    With a lot smaller offset (5px): http://jsfiddle.net/pixelass/nPjQh/13/

    (the content has the same opacity as the circle)

    How does the offset work?

    Control the background-size vs. the top and left

    Rules:

    top = left;

    background-size = elementHeight * 2 + top * 2;

    Look at the flower (it is also only one <div> with pseudo-elements)
    the background-size is bigger than the circle. which creates the green leaves on the bottom

    http://jsfiddle.net/pixelass/nPjQh/15/

    one div makes a flower


    CURRENT PROBLEM


    See this fiddle: http://jsfiddle.net/pixelass/nPjQh/16/

    If not using another layer as seen in the examples at the top of the post the content will be transparent. So if you only need an image inside the circle the above examples will work fine.

    conent is transparent

    HOW TO SOLVE THIS ISSUE

    If you need a canvas or another div inside the circle you would have to put the circle on the div and layer the needed div over the circle

    See this fiddle: http://jsfiddle.net/pixelass/nPjQh/17/

    change around a little and it will work fine. GET THE CODE FROM THE FIDDLE

    correcting the opacity issue


    Different shape /advanced Styling


    If you use a different shape with flat sides, you could even put a border around the sum of the two divs.. or even add a box shadow

    still using the simple markup of….

    <div id="foo">
        <div id="bar">
        </div>
    </div>
    

    See the fiddle for the box-shadow: http://jsfiddle.net/pixelass/nPjQh/21/

    adding a box-shadow


    Apply a border to the circle


    Using -webkit-mask-image we could add a border to the circle.
    http://jsfiddle.net/pixelass/nPjQh/24/

    border on round element


    More examples:


    Four circles around the div

    http://jsfiddle.net/pixelass/nPjQh/25/

    Markup:

    <div id="foo">
        <div id="bar1"></div>
        <div id="bar2"></div>
        <div id="bar3"></div>
        <div id="bar4"></div>
    </div>
    

    4 circles

    Using this technique to make a tooltip

    http://jsfiddle.net/pixelass/nPjQh/31/

    Markup:

    <div id="foo">
        <div id="bar"></div>
        I am a pure css tooltip with a semi-transparent background and a black border. <br/>
        My width is static an my height is dynamic...
    </div>
    

    css tooltip

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

Sidebar

Related Questions

http://jsfiddle.net/waitinforatrain/sEX3n/ I have two divs in a container with absolute position. Both of them
I have two divs inside a div, I want them both adjacent to each
i have two divs with the same ids but one has display=none and the
I have two sibling divs sitting below each other, both contained in the same
I currently have two divs on my site: Notice that both have border [same
Here I have two divs with a css background images set for both. I'm
Situation: I have two fixed-height divs, overflow set to hidden on both, and dynamic
I have two Divs that are floated right, but I would like one to
I have two divs, one inner and one outer, but the inner div is
I have two divs, both with position:absolute; , one inside the other. The parent

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.