【发布时间】:2018-12-31 18:01:24
【问题描述】:
我正在尝试将 URL 图像从 Angular 中的 html 传递给我的 CSS,但我不能这样做:
我的 CSS 是:
card-profile_visual {
height: $visual-height;
overflow: hidden;
position: relative;
background: linear-gradient(to bottom, darken(#545559, 10%), saturate(darken(#3A4A7B, 2%), 20%), saturate(darken(#3A4A7B, 15%), 20%));
&:before,
&:after {
display: block;
content: '';
width: 100%;
height: 100%;
position: absolute;
z-index: 0;
background: url(myUrl) no-repeat center center/cover;
opacity: 0.5;
mix-blend-mode: lighten;
}
}
我的 html 是:
<div class="card-profile_visual" [style.background-image]="'url('+offer.photo_url+')'"></div>
如何实现这一点,以将 offer.photo_url 传递给 CSS 中:
背景:url(myUrl) 不重复中心中心/封面;
非常感谢你
【问题讨论】:
-
我认为没有纯 CSS 方法可以做到这一点。见这里:stackoverflow.com/questions/26967890/… —
background: url(attr(style));只在你的梦里!
标签: javascript css angular sass