[英]Overlay using a pseudo-element
<div class="box small">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<div class="detail"> for more info click below</div>
<div class="read-more"> click</div>
</div>
Css CSS
.detail{
position: relative;
}
.detail:after{
content: "";
display: block;
position: fixed; /* could also be absolute */
bottom: 0;
left: 0;
height: 100%;
width: 20%;
z-index: 10;
background-color: rgba(0,0,0,0.2)
}
I wan to add a background for these two divs : 我想为这两个div添加背景:
<div class="detail"> for more info click below</div>
<div class="read-more"> click</div>
I can't add a wrapper div , so i'm using overlay Technique: 我不能添加包装div,所以我正在使用叠加技术:
How can i relative overlay to parent box ? 我如何相对覆盖到父框?
i don't know if i got what you want right but here what i think you are trying to do 我不知道我是否满足您的要求,但是我认为您正在尝试这样做
.box {
padding:20px;
border:1px solid #000;
position:relative;
}
.small {
width:200px;
height:200px;
}
.detail{
position: relative;
}
.box:after{
content: "";
display: block;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
background-color: rgba(0,0,0,0.2);
right:0;
bottom:0;
height:100%;
width:100%;
}
and the html 和HTML
<div class="box small">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<div class="detail"> for more info click below</div>
<div class="read-more"> click</div>
</div>
If you don't want to wrap these two div detail and read-more Then try this.... 如果您不想包装这两个div 详细信息并阅读更多内容 ,请尝试...。
HTML HTML
<div class="box small">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
<div class="detail"> for more info click below</div>
<div class="read-more"> click</div>
</div>
CSS CSS
.detail,.read-more
{
position: relative;
}
.detail:after,.read-more:after{
content: "";
display: block;
position: absolute;
bottom: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
background-color: rgba(0,0,0,0.2)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.