Created
May 29, 2017 20:14
-
-
Save apphp/91b516a70b61fc03aa46d98a9b17e0e1 to your computer and use it in GitHub Desktop.
Non-Transparent Inside Transparent Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
/* source: http://www.apphp.com/index.php?snippet=css-non-transparent-inside-transparent-elements */ | |
.bar { | |
height: 4em; | |
padding-top: 2em; | |
opacity: 0.5; | |
background: black; | |
border-top: 3px solid #ccc; | |
border-bottom: 3px solid #ccc; | |
margin-top: 5.0em; | |
} | |
h2.ontop { | |
position: relative; | |
top: 4.7em; | |
} | |
</style> | |
<div class="bar"> | |
<h2>Text in this bar inherits the transparency.</h2> | |
</div> | |
<h2 class="ontop">Text in this bar stays opaque.</h2> | |
<div class="bar"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment