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;
   
}

CSS linear gradient generator:
https://www.colorzilla.com/gradient-editor/
background: linear-gradient(to bottom, #b4e391 0%,#61c419 50%,#b4e391 100%)

评论

此博客中的热门博文

通过Graphql成功地查询Contentful,以便在我的gatsby项目中访问和显示图像

Oracle忘了保存,Oracle Cloud甲骨文云服务器忘记SSH秘钥或未设置Public key的解决办法...

Nginx【Docker系列】一个反向代理神器——Nginx Proxy Manager