background-attachment蒙板
INDEX.HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Tutorial</title>
<link rel="stylesheet" href="styles.css">
</head>
<body >
<div class="banner">
<h1>hello world</h1>
</div>
<div class="header">
<h1>hello people</h1>
</div>
</body>
</html>
CSS:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
div {
min-height: 70vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 60px;
color: orange;
}
.banner {
background: url(./detox.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
}
.header {
background: linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)),
url('./detox.jpg')center/cover no-repeat fixed;
}
https://www.colorzilla.com/gradient-editor/
background: linear-gradient(to bottom, #b4e391 0%,#61c419 50%,#b4e391 100%)
评论
发表评论