【发布时间】:2015-08-09 01:18:28
【问题描述】:
我有这个代码
body {
background-color: #808080;
background-image: url('/Content/img/emboss.png');
background-repeat: no-repeat;
background-position: center 250px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 10pt;
opacity: 0.8;
}
img {
opacity: 1;
}
但是它不起作用。整个网站,每个元素的不透明度都是 0.8,这是我想要的,而且看起来很完美。但是,在渲染图像时,我不需要任何透明度。
我将如何在我的 css 中执行此操作
【问题讨论】:
-
我不认为你可以覆盖孩子的父母不透明度:stackoverflow.com/questions/21886830/…
-
body 中的元素可以有最大不透明度作为其父元素,
.8。将opacity: .8设置为不包含img的元素,而不是body。 -
如果你不介意在正文中使用
background: rgba(0, 0, 0, 0.4); -
覆盖 img 的不透明度
标签: css transparency opacity