CSS毛玻璃背景

源码分享 · 05-13 15:56

给大家分享一个简单的纯CSS毛玻璃特效,用毛玻璃背景以其独特的美学效果备受追捧。这种背景不仅赋予网站一种柔和、朦胧的感觉,还能提升用户的视觉体验。

效果展示

IMG_5661.jpeg

该展示图为截图效果,实际效果是动态的,更佳炫酷!

代码实现

1.HTML代码

<div class="container">
        <div class="bg">
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="glass">
            <div class="text">刘郎阁</div>
            <input type="text" placeholder="用户名">
            <input type="password" placeholder="密码">
            <button>➝</button>
        </div>
    </div>

2.CSS代码

*{
    margin: 0;
    padding: 0;
    font-family:  Helvetica, sans-serif;
}
body{
    background: #222;
}
.container{
    width: 800px;
    height: 800px;
    margin: 0 auto;
    position: relative;
}
.bg{
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    animation: bgscale ease-in-out 1s;
}
.bg span{
    background-color: #fff;
    position: absolute;
    top: 117px;
    left: 143px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    box-shadow: 1px 1px 50px #000;
    background: purple;
}
.bg span:nth-child(1){
    animation: move ease-in-out 3s infinite alternate;
}
.bg span:nth-child(2){
    top: 518px;
    left: 434px;
    width: 200px;
    height: 200px;
    background: orange;
    animation: move ease-in-out 4s infinite alternate-reverse;
}
.bg span:nth-child(3){
    top: 196px;
    left: 483px;
    width: 60px;
    height: 60px;
    background: cyan;
    animation: move ease-in-out 2.5s infinite alternate;
}
input{
    background: transparent;
    outline: none;
    border: none;
    border-bottom: 1px solid #666;
    width: 100%;
    height: 45px;
    color: #eee;
    font-size: 18px;
    
    margin-top: 40px;
}
.text{
    width: 100%;
    font-size: 26px;
    text-align: left;
    margin-top: 50px;
}
button{
    border: none;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    color: #eee;
    font-weight: bold;
    font-size: 28px;
    cursor: pointer;
    margin-top: 70px;
    background: rgba(255,255,255,0.1);
    box-shadow: 0px 2px 10px #111;
    transition: all ease-in-out .2s;
}
button:hover{
    width: 160px;
    border-radius: 70px;
    box-shadow: 0 0 10px #999,inset 0 0 5px #333;
}
.glass{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    width: 360px;
    height: 480px;
    padding: 0 40px;
    box-sizing: border-box;
    top: 160px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px;
    color: #eee;
    background-color: rgba(255,255,255,0.05);
    /* 设置模糊和阴影 */
    backdrop-filter: blur(4px);
    box-shadow: inset 1px 1px 6px rgba(255,255,255,0.3),
    2px 2px 15px rgba(0, 0, 0, 0.5);
    animation: formfadein ease-out 1s .2s backwards;
    transition: all ease-in-out .2s;
}
.glass:hover{
    box-shadow: inset 1px 1px 3px rgba(255,255,255,0.9),
    4px 4px 25px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(7px);

}
/* 圆点上下浮动动画 */
@keyframes move{
    0%{
        transform: translateY(0);
    }
    100%{
        transform: translateY(-30px);
    }
}
/* 背景进入动画 */
@keyframes bgscale{
    0%{
        transform: scale(0,0) rotateZ(60deg);
    }
    100%{
        transform: scale(1,1) rotateZ(0);
    }
}
/* 表单淡入动画 */
@keyframes formfadein{
    0%{
        transform: translate(-50%,28px);
        opacity: 0;
    }
    100%{
        transform: translate(-50%,0);
        opacity: 1;
    }
}

完!

特效 组件 优化 源码分享

上一篇 : JS方法备用方案

下一篇 : 网页点击特效:显示文字


  1. HowieHz   Lv1
    06-18 18:52 第8楼 中国上海市移动Windows 10 · Google Chrome

    学习了!

  2. 肖寒武   Lv1
    05-14 09:00 第7楼 中国浙江省杭州市联通Windows 10 · Google Chrome

    不错不错

  3. 游龙生   访客
    05-14 08:41 第4楼 亚太地区iPhone · Safari

    推荐你个GIF图片录制小工具:ScreenToGif,文章如果要插演示动图,这个好用一些

    1. 刘郎   博主
      05-14 08:45 第5楼 中国贵州省移动iPhone · Safari
      @游龙生

      👍有机会我去试试

  4. 05-14 00:14 第3楼 中国山西省移动Android · Google Chrome

    感觉分享,已经让我两次获得灵感,知道我要收集点什么
    https://echs.top/vps
    这个页面有两个板块灵感来自你这里

    1. 刘郎   博主
      05-14 08:46 第6楼 中国贵州省移动iPhone · Safari
      @二次寒树

      😂常来

  5. obaby   Lv2
    05-13 17:15 第1个脚印 中国山东省青岛市联通iPhone · Google Chrome

    主打一个迅速,为啥我的每次都要审核

    1. 刘郎   博主
      05-13 17:18 第2楼 中国贵州省移动iPhone · Safari
      @obaby

      之前有个老朋友给我评论区搞了一堆乱七八糟的东西,所以开了审核,每个人都先过审核再说😂

| 黔ICP备2024020400号-1 | 萌ICP备20246777号 | | 当前有 2 人在线 |
本站已加入BLOGS·CN
yjvc.cn
博友圈 星球穿梭
开往-友链接力