S
S
svilkov872015-09-21 20:09:37
css
svilkov87, 2015-09-21 20:09:37

How to set opacity for the second block?

Hi all!
There are two divs - block and inside it another div -block2. By setting the opacity property of block, block2 also takes that value. And I don't need block2 transparency. How to solve the problem?
The code.
Thank you.

<div class="block">
   <div class="block2">    
   </div>
</div>

<code lang="css">
.block{
    background: #4E4E4E;
    width: 200px;
    height: 200px;
    opacity: 0.5;
    border: 1px solid #636363;
  }
.block2{
    background: red;
    width: 90px;
    height: 90px;
    outline: 1px solid #fff;
    margin: 50px;
}
</code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-09-21
@svilkov87

Set a semi-transparent background if possible.
Using the rgba function or a single pixel image.

.block{
    background: rgba(78, 78, 78, 0.5);
    width: 200px;
    height: 200px;
    border: 1px solid #636363;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question