系统:Linux Mint 编辑:Atom(来自 GitHub) 浏览器:Linux 版 Google Chrome (43.0)
问题:为了在代码的 CSS 部分中设置类 biobox 的 div 样式,我尝试使用 background-color:rgb(0,0,0,0.5) 获得半透明背景。这导致根本没有背景。如果我删除 0.5(alpha/transparency.opacity 值),我会得到一个应用于 div 的不透明黑色背景。可能是什么原因造成的?
h1 {
font-famiy: Verdana;
color: #090956;
}
.biobox {
font-family: cursive;
background-color: rgb(0, 0, 0, 0.3);
color: #090956;
margin: 20px;
padding: 20px;
}
body {
background: url('bg.jpg') no-repeat center center fixed;
-webkit-backgound-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
<h1>This is Big Header</h1>
<div class="biobox">
<p>This is a subtitle to the header!</p>
</div>
<p>More bio crap!</p>
最佳答案
您需要使用 rgba(0, 0, 0, 0.3);
而不是 rgb(0, 0, 0, 0.3);
关于html - CSS/HTML : Alpha setting applied to background-color makes it disappear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30462816/