【发布时间】:2017-08-09 17:22:01
【问题描述】:
我有一个带有背景图像的<div>,我希望背景图像应用过滤器。但我还希望 div 包含覆盖图像的 <p> 标签——我不希望 <p> 具有相同的过滤器。
如何清除<p>中<div>设置的过滤器?
到目前为止我得到了什么:
<div className="artistDetailImage" style={{backgroundImage: url(${this.props.artistImage})`}}>
<p className="artistDetailText">{name}</p>
</div>
.artistDetailImage {
background-size: cover;
background-position: top;
width: 100%;
height: 300px;
filter: contrast(60%);
}
.artistDetailText {
width: 100%;
font-size: 20px;
text-align: left;
padding-left: 5px;
position: relative;
top: 240px;
filter: none; //Have also tried contrast(100%), brightness(1), etc.
color: white;
}
这个答案似乎有效,但我希望有更好的方法来做到这一点。 https://stackoverflow.com/a/32677739/3010955
【问题讨论】:
-
你不能在 CSS 的 child 元素中重置过滤器...
-
过滤器总是应用于整个事情!
-
好吧,很高兴知道。我找到了另一个有解决方案的 SO 答案,我只是想看看是否有更好的方法。
标签: html css css-filters