* {
margin: 0;
padding: 0;
}
html,
body {
box-sizing: border-box;
height: 100%;
}
.wrapper-overlay {
background: rgba(72, 70, 82, 0.5);
}
body {
color: white;
min-height: 100%;
min-width: 100%;
background: url("images/friends.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
position: relative;
}
<html>
<wrapper-overlay>
<body>
</body>
</wrapper-overlay>
</html>
我制作的背景是其父元素的 100%,但是 background:rgba 不会使背景的底部变暗。我尝试将背景放在 html css 中,但它也不起作用。
最佳答案
我了解到您想对整个页面应用深色背景。 看起来你应该使用 min-height 属性。这是使用的基本逻辑:
<style>
html,body{
height:100%;
min-height:100%;
}
body{
background:rgba(72, 70, 82, 0.5);
}
</style>
<html>
<body>
</body>
</html>
关于css - 我应该如何使我 body 的整个背景变暗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54856147/