先上代码,后看效果;
<!DOCTYPE html>
<html lang="en" style="filter:grayscale(0%)">
<!--
style="filter:grayscale(0%)" 正常颜色
style="filter:grayscale(100%)" 全部灰色
-->
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.bodys{
width: 400px;
height: 400px;
background-color: red;
border:1px solid #ccc;
}
.box{
width: 300px;
height: 300px;
background-color: yellow;
border:1px solid #ccc;
}
.child{
width: 200px;
height: 200px;
background: blue
}
</style>
</head>
<body>
<div class="bodys ">
<div class="box">
<div class="child"></div>
</div>
</div>
</body>
</html>