1.HTML+CSS写个8

用HTML+CSS创意绘制数字8
本文介绍了一种使用HTML和CSS实现创意数字8显示的方法。通过精心设计的CSS动画,数字8不仅呈现了独特的视觉效果,还展示了旋转和颜色变化的功能。作者分享了代码细节,包括如何利用transform和keyframes实现动画效果。

感想: 有点缺陷。效果地址:https://codepen.io/flyingliao/pen/QobdyE

HTML code:

<div class="eight">
  <span><span></span></span>
  <span></span>
</div>

CSS code:

html, body ,.eight{
    margin: 0;
    padding: 0;
}
body{
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.eight{
    width: 80px;
    height: 160px;
}
.eight>span{
    display: block;
    width: 100%;
    height: 50%;
    border: 1px solid white;
    border-radius: 50%;
    transform: rotate(-45deg);
}

.eight span:first-child{
    /* alternate: 动画轮流反向播放 ;
    forwards: 动画完成保持最后一个属性值;
    animation-name: write1;
    animation-duration: 2s;
    animation-timing-function: ease-in;
    animation-iteration-count:1;
    animation-fill-mode: forwards;
   */
    animation: write1 2s ease-in 1 forwards;
}
.eight span:last-child{
    margin-top: -1px;
    animation: write2 4s ease-in 2s forwards;
}
.eight>span:first-child>span{
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    border: 1px solid white;
    border-radius: 50%;
    transform: rotate(-deg45);
    animation: write3 2s ease-in 3s forwards;
}
@keyframes write1{
   0%{
      border-top-color: white;
      border-left-color: white;
   }
   100%{
      border-top-color: red;
      border-left-color: red;
   }
}
@keyframes write2{
    0%{
        border-right-color: white;
    }
    25%{
        border-right-color: red;
    }
    50%{
        border-right-color: red;
        border-bottom-color: red;
    }
    75%{
        border-right-color: red;
        border-bottom-color: red;
        border-left-color: red;
    }
    100%{
        border-color: red;
    }
}
@keyframes write3{
    0%{
       border-bottom-color: white;
       border-right-color: white;
    }
   100%{
       border-bottom-color: red;
       border-right-color: red;
   }
}

 

posted on 2019-02-27 20:34 人生与戏 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/FlyingLiao/p/10446650.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值