蚂蚁线-css(3)

主要知识点:

linear-gradient
animation
background-clip:text

纯css实现类似ps中的蚂蚁线

效果图片
myx.png
html文件
 <div class="item-box"><div class="text">蚂蚁线</div></div>  
css文件
   .item-box {
            width: 400px; height: 200px;line-height: 200px;text-align: center;margin:auto;
            border: 1px solid #ccc;
            background: linear-gradient(#efefef,#ccc) padding-box,
            linear-gradient(135deg, rgba(0, 0, 0, 1) 25%, transparent 25%, transparent 50%, rgba(1, 1, 1, 1) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
            background-size:100% 100%, 8px 8px;
            animation: bg 1s linear infinite;
        }
        .item-box:hover{
            cursor: pointer;
            border: 1px dashed transparent;
        }
        .text{
            height: 100%;
            font-weight: bold;
            -webkit-text-stroke: 2px #999;
            color: #999;
            font-size: 90px;

            background-image: linear-gradient(135deg, rgba(0, 0, 0, 1) 25%, transparent 25%, transparent 50%, rgba(1, 1, 1, 1) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
            background-size: 8px 8px;
            animation: bg 1s linear infinite;
            -webkit-background-clip: text;
        }
        .text:hover{
            -webkit-text-stroke: 2px transparent;
        }

        @keyframes bg {
            0% {
                background-position: 0 0;
            }
            100% {
                background-position: 8px 0;
            }
        } 

demo 请在chrome下预览(未写兼容性)

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

相关阅读更多精彩内容

友情链接更多精彩内容