CSS 实现 光圈效果

主要利用css3 animation, 在0 ~ 100% 过渡中让box-shadow渐变(box-shadow只需要设置blur 和spread)
HTML:

<div class="wrapper">
        <div class="bg"></div>
        <div class="circle"></div>
    </div>

CSS:

.wrapper {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background-color: #ff6633;
    position: relative;
}
.bg {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: absolute; 
    top: 0;
    left: 0;
    animation: pulse 5s infinite;
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 8px 6px #fff;
    }
    50% {
        box-shadow: 0 0 8px 6px #ff6633;
    }
    100% {
        box-shadow: 0 0 8px 6px #fff;
    }
}
.circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #efefef;
}

预览效果入如下:


test1.gif
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容