< div id = "container" >
< h1 > Hi, I'm a transparent block </ h1 >
Text inside the block. Text inside the block. Text inside the block.
</ div >
< div id = "container" >
< div class = "transparency" >
<! - This is a transparent block ->
</ div >
< div class = "content" >
< h1 > Hi, I'm a transparent block </ h1 >
Text inside the block. Text inside the block. Text inside the block.
</ div >
</ div >
#container {
padding: 20px;
width: 300px;
color: #FFFFFF;
position: relative;
float: left;
margin-left: 20px;
overflow: hidden;
}
#container .transparency {
opacity: 0.5;
filter: alpha (opacity = 50);
-moz-opacity: 0.5;
background-color: # 000000;
width: 340px;
height: 1500px;
position: absolute;
top: 0px;
left: 0px;
z-index: -1;
}
.content {
position: relative;
}
transp
class to your block:< div id = "container" class = "transp" >
< h1 > Hi, I'm a transparent block </ h1 >
Text inside the block. Text inside the block. Text inside the block.
</ div >
$ ( document ) .ready ( function () {
$ ( ".transp" ) .wrapInner ( '<div>' ) .children (). addClass ( "content" );
$ ( ".transp .content" ) .before ( '<div>' ) .prev (). addClass ( "transparency" );
});
View demo
Download demo
Subscribe to Chernev's notes
Source: https://habr.com/ru/post/30565/
All Articles