我有一个主目录,其中有一个背景图像与filter:blur和一个box-shadow覆盖。
如何在包含的div上覆盖父div中的filter:blur和box-shadow?
以下是我的尝试:
<style type="text/css">
#home_main {
margin: -30px;
background-size: cover;
padding: 0;
background-image: url('img/bg.jpg') !important;
filter: blur(2px);
overflow: hidden;
box-shadow: inset 0 0 0 1000px rgba(0,0,0,.3);
}
body {
overflow: hidden !important;
}
#home_content {
text-align: center;
color: #fff !important;
font-weight: 600;
position: fixed;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
text-shadow: none;
font-family: 'Open Sans' !important;
filter: initial !important;
box-shadow: initial !important;
}
#home_content h1 {
font-size: 42px;
font-weight: bold;
}
</style>
<div id="home_main">
<div id="home_content">
Info Management System
</div>
</div>发布于 2016-09-22 02:16:38
您可以在这两个div周围添加一个包装器。你已经在使用定位了。
.wrap { position: relative; }
#home_main {
margin: -30px;
background-size: cover;
padding: 0;
filter: blur(2px);
overflow: hidden;
box-shadow: inset 0 0 0 1000px rgba(200,0,0,.3);
/* added so the div shows here */
width: 300px;
height: 300px;
background-image: url('https://static.pexels.com/photos/130763/pexels-photo-130763.jpeg');
}
#home_content {
text-align: center;
color: #fff ;
font-weight: 600;
position: absolute;
z-index: 2;
top: 40%;
transform: translateY(-50%);
width: 240px; /* width of image div minus it's negative margins */
}
#home_content h1 {
font-size: 42px;
font-weight: bold;
}<div class="wrap">
<div id="home_content">
Info Management System
</div>
<div id="home_main"></div>
</div>
这将允许您仅将滤镜和长方体阴影应用于其中一个div。但作为直接子对象,您不能删除父对象的滤镜或长方体阴影。与不透明度非常相似,一些属性会影响父对象及其所有子对象。
https://stackoverflow.com/questions/39623513
复制相似问题