css不为人知的属性
相邻兄弟选择器之常用场景
https://user-gold-cdn.xitu.io/2019/7/29/16c3d4f579c4de52?imageslim
要使模态框背景透明,用rgba是一种简单方式
https://user-gold-cdn.xitu.io/2019/7/29/16c3d4fb360585bf?imageslim
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
height: 10000px;
}
.wrapper{
display: flex;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.3);
}
.box{
background-color: red;
width: 200px;
height: 200px;
margin: auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="box">文字</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
height: 10000px;
}
.wrapper{
display: flex;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.mask{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
/* background-color: rgba(0, 0, 0, 0.3); */
background: black;
opacity: 0.5;
}
.box{
background-color: red;
width: 200px;
height: 200px;
margin: auto;
}
</style>
</head>
<body>
<div class="mask"></div>
<div class="wrapper">
<div class="box">文字</div>
</div>
</body>
</html>

浙公网安备 33010602011771号