美文网首页
CSS3 毛玻璃

CSS3 毛玻璃

作者: Ray_afab | 来源:发表于2020-07-19 12:21 被阅读0次

    不废话 分享最直接的代码

    WX20200719-122440.png
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
        <main class="bg"></main>
        <section class="container">
          i am lhyt
        </section>
    </body>
    <style>
          .bg,
          .container::before {
            background-image: url("http://img2.imgtn.bdimg.com/it/u=1737072847,1699534261&fm=26&gp=0.jpg");
            background-repeat: no-repeat;
            background-size: cover;
            background-attachment: fixed;
          }
          .bg {
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            position: absolute;
            z-index: -1;
          }
    
          .container::before {
            content: "";
            filter: blur(20px);
            z-index: -1;
          }
    
          .container {
            background: rgba(0, 0, 0, 0.5);
            color: #fff;
            font-size: 30px;
            /* 用transform会悲剧哦 */
            left: calc(50% - 250px);
            top: calc(50% - 200px);
          }
    
          .container,
          .container::before {
            width: 500px;
            height: 400px;
            position: absolute;
            border-radius: 8px;
          }
    
          
    </style>
    </html>
    

    相关文章

      网友评论

          本文标题:CSS3 毛玻璃

          本文链接:https://www.haomeiwen.com/subject/abmlkktx.html