html - 具有透明颜色覆盖的背景图像上的 mask 元素

标签 html css background transparency transparent

sample transparency

这是我努力实现的例子。 body 有背景图像。图像上方是不透明层。然后我得到了元素列表,应该屏蔽哪些背景以使其完全透明。

CSS甚至可以吗?
演示失败:link

HTML 结构:

<div id="opacity">
    <ul>
        <li>
            <div class="mask">
                <a class="fancybox" rel="group" href="#">
                    <img src="name.png" class="thumb" />
                </a>
            </div>
        </li>
        <li>
            <div class="mask">
                <a class="fancybox" rel="group" href="#">
                    <img src="name.png" class="thumb" />
                </a>
            </div>
        </li>
    </ul>  
</div>

最佳答案

我知道你可以伪造它的方法是在 mask 容器上设置图像并添加属性

 background-attachment: fixed;

像这样:

.mask {
   background-image: url(http://justbeecosmetics.com/img/headImage.jpg); 
   background-attachment: fixed;
   background-size: cover;
}

检查更新 Demo

来自 W3

The background-attachment property specifies whether a background image is fixed with regard to the viewport or scrolls along with the containing block.

默认值是scroll然后如果你将它设置为fixed

The background image does not scrolls with the element.

附加到视口(viewport)。

关于html - 具有透明颜色覆盖的背景图像上的 mask 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25868476/

相关文章:

javascript - jQuery取消快速悬停 Action 列表的下拉/滑动

html - Github页面404找不到文件

css - 卡住屏幕顶部的 <div>,让剩余的 <div> 填满屏幕并滚动

ios - 应用程序终止时停止位置更新

android - notifydatasetchanged() 无法正常工作

javascript - jquery 移动内容垂直居中

css - 将 float <p> 拖放到 float 父级 <div> 的底部

html - 响应式设计不适用于文本

javascript - 悬停在不同的 div 上时背景图像发生变化

javascript - HTML - 覆盖状态栏链接位置显示