Skip to content

Instantly share code, notes, and snippets.

@csasbach
Created March 13, 2011 00:18
Show Gist options
  • Save csasbach/867733 to your computer and use it in GitHub Desktop.
Save csasbach/867733 to your computer and use it in GitHub Desktop.
Cross browser opacity that stops inheritance.
.startOpacity{
background:rgb(255,255,255);
background:rgba(255,255,255,0.7);
-ms-filter:alpha(opacity=70);
filter:alpha(opacity=70)
}
.stopOpacity{
position:relative
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="xBrowserOpacity.css" />
</head>
<body style="background-color:#888">
<ul class="startOpacity" style="padding:8px;list-style:none">
<li style="background-color:#f00;padding:2px 4px;margin-bottom:8px">In some browsrs, this background is just as transparent as the container's background.</li>
<li class="stopOpacity" style="background-color:#f00;padding:2px 4px;">This background is fully opaque in all browsers.</li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment