我有以下标记
<body>
<div class="holder">
<div class="circle"></div>
</div>
</body>
并且我已经将固定背景应用于 body 元素,将白色背景应用于 class holder
body {
background: url(image.png);
background-attachment: fixed;
}
.holder {
width: 500px;
height: 500px;
background: #fff;
}
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background: rgba(0, 0, 0, 0);
}
我尝试做的是使圆圈透明以查看正文背景。简单地说,我正在尝试的是,使圆圈透明以查看 body 背景图像,而圆圈周围的白色背景仍然存在。请原谅我的英语。伙计们请帮助我。
最佳答案
您要求执行的操作将无法使用透明度。
但是,有一个解决方法是完全可以接受的:
body {
background: url(http://placekitten.com/g/400/500);
background-attachment: fixed;
}
.holder {
width: 500px;
height: 700px;
background: rgba(255,255,255,0.8);
border: 1px dotted blue;
}
.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background: url(http://placekitten.com/g/400/500);
background-attachment: fixed;
}
查看演示:http://jsfiddle.net/audetwebdesign/FqMXz/
只需将相同的背景图像应用到 .circle
div。
这个技巧取自 Eric Meyer 的一本 CSS 书籍。
关于html - 将一个div变成透明的以透视两个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16987203/