CSS3 仿京东边框从中间逐渐放大效果

本文介绍了一种使用CSS3实现的动态边框效果。通过transform的scale属性和transition属性来制作当鼠标悬停在元素上时显示的动画边框。代码简单易懂,适合初学者学习。

昨天看一个朋友发的京东的效果 然后就自己扒了下来  确实感觉到css3的强大 





话不多说 贴代码

<style>
  #box{
    width: 300px;
    height: 300px;
    transition: all 5s;
    position: relative;


  }
  #box ::before{
    content: "";
    position: absolute;
    bottom: -1px;
    left: -1px;
    right: -1px;
    top: -1px;
    transform:scale(1, 0);
    transition: all 1s;
    border-left: 1px solid red;
    border-right: 1px solid red;
  }


    #box ::after{
    content: "";
    position: absolute;
    bottom: -1px;
    left: -1px;
    right: -1px;
    top: -1px;
    transform:scale(0, 1);
    transition: all 1s;
    border-top: 1px solid red;
    border-bottom: 1px solid red;
    
  }
   #box:hover ::before , #box:hover ::after {
    transform:scale(1);
     transition:all 1s;
   }
</style>
  <div id="box"><p>Hi~ o(* ̄▽ ̄*)ブ</p></div>


主要运用的是css3的transform的scale放大和过度时间transition   当然可以加上透明度opacity的变化 效果更好  

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值