嗯,我有一个白色背景,不透明度较低。但是文本和soundcloud小部件也会降低不透明度。如何使不透明度只影响背景?
HTML:
<div class="music">
<h1>Music I used</h1>
<h3>On this page you can find all the music I used in my skill compilations</h3>
<div class="song-1">
<iframe width="350" height="350" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/117698423&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>
</div>
<div class="song-2">
<iframe width="350" height="350" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/164076894&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>
</div>
</div>
的CSS:
.music {
background-color: white;
opacity: .6;
width: 800px;
min-height: 900px;
position: absolute;
left: 524.5px;
right: 524.5px;
}
.song-1 {
position: absolute;
left: 30px;
float: left;
}
.song-2 {
float: right;
position: absolute;
right: 30px;
}
.music h1 {
text-align: center;
}
.music h3 {
text-align: center;
}
答案 0 :(得分:1)
您需要的是 - 在背景上应用不透明度,而不是在整个元素上应用。
使用以下内容替换.music
css类:
.music {
background:rgba(255,255,255,0.6);
width: 800px;
min-height: 900px;
position: absolute;
left: 524.5px;
right: 524.5px;
}
(已删除opacity
和background-color
并添加了background:rgba(...)
)