Reputation: 327
The CSS overflow: visible property allows to render content outside the element box. However, Firefox renders the content that overflows the box with a transparent background that makes visible what is below it. E.g.:
<div style="background:red;height:30px;"> I want this to have<br> an opaque background. </div> <div style="background:white"> So that it does not show what is below. </div>
Is there a way of making all the contents of the first div be rendered with an opaque background?
Upvotes: 3
Views: 1081
Reputation: 67194
Like this:
HTML:
<div class="myDiv">
I want this to have<br>
an opaque background.
</div>
<div class="mySecondDiv">
So that it does not show what is below.
</div>
And this CSS:
.myDiv
{
background:red;
height:30px;
opacity: .75; /* Standard: FF gt 1.5, Opera, Safari */
filter: alpha(opacity=75); /* IE lt 8 */
-ms-filter: "alpha(opacity=75)"; /* IE 8 */
-khtml-opacity: .75; /* Safari 1.x */
-moz-opacity: .75; /* FF lt 1.5, Netscape */
}
.mySecondDiv
{
background:white;
}
This will render your element with whichever opacity you want in most browsers (I'm not sure how many will pick this up).
Upvotes: 0
Reputation: 72222
This is one solution.
Here's the code with an example.
Upvotes: 1