button 元素的css3旋轉動畫


html: 利用偽元素

<button class="btn btn-default btn-lg btn-3d" type="submit" data-hover="SUBMIT REQUEST">
"SUBMIT REQUEST"
</button>

css:

.btn-3d {
   position: relative;
   perspective: 800px;
   transition: background 0.6s;
   transform-origin: 50% 0;
   transform-style: preserve-3d;
}

.btn-3d::before {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background: red;
   border-radius: inherit;
   color: inherit;
   content: attr(data-hover);   //綁定hover事件
   transform: rotateX(270deg);  //css旋轉270度
   transition: transform 0.6s;   //過渡效果
   transform-origin: 0 0;      //css旋轉軸
   pointer-events: none;
   padding: inherit;
   font: inherit;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM