CSS效果集錦(持續更新中)
高亮光弧效果
使用CSS3實現的一個高亮光弧效果,當滑鼠hover到某一個元素上時,一道光弧從左向右閃過,效果如下:
程式碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>light</title> <style> body{ margin: 0; } a.floor{ display: block; height: 475px; } a.floor:hover:before{ -webkit-transition: left 1.5s; -moz-transition: left 1.5s; transition: left 1.5s; left: 920px; } a.floor:before{ content: ""; position: absolute; width: 80px; height: 475px; top: 0; left: -150px; overflow: hidden; background: -moz-linear-gradient(left,rgba(255,255,255,0)0,rgba(255,255,255,.2)50%,rgba(255,255,255,0)100%); background: -webkit-gradient(linear,left top,right top,color-stop(0%,rgba(255,255,255,0)),color-stop(50%,rgba(255,255,255,.2)),color-stop(100%,rgba(255,255,255,0))); background: -webkit-linear-gradient(left,rgba(255,255,255,0)0,rgba(255,255,255,.2)50%,rgba(255,255,255,0)100%); background: -o-linear-gradient(left,rgba(255,255,255,0)0,rgba(255,255,255,.2)50%,rgba(255,255,255,0)100%); -webkit-transform: skewX(-25deg); -moz-transform: skewX(-25deg); } </style> </head> <body> <a class="floor" href="javascript:;"> <img src="./images/girl.jpg" height="475" width="760" alt=""> </a> </body> </html>
滑鼠hover圖片突出顯示
類似於今日頭條首頁的圖片,當滑鼠hover到上面的時候會著重顯示圖片(放大效果):
程式碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>hover</title> <style> body{ margin: 0; } .img-wrap { width: 194px; height: 108px; float: left; margin-left: 6px; background: #e8e8e8; border: 1px solid #e8e8e8; overflow: hidden; cursor: pointer; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; } .img-wrap img { width: 100%; height: 100%; border: 0; -webkit-transition: all .5s ease-out .1s; transition: all .5s ease-out .1s; } .img-wrap:hover img { -webkit-transform: matrix(1.04,0,0,1.04,0,0); -ms-transform: matrix(1.04,0,0,1.04,0,0); transform: matrix(1.04,0,0,1.04,0,0); -webkit-backface-visibility: hidden; backface-visibility: hidden; } </style> </head> <body> <a class="img-wrap" target="_blank" href="/group/6347460154771013889/"> <img alt="" src="http://p3.pstatp.com/list/640x360/e59000a6ecaab7d1535"> </a> </body> </html>
滑鼠hover圖片移動
向上移動:
程式碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>hover</title> <style> body{ padding: 4rem; } .img-wrap { width: 194px; height: 108px; display: block; cursor: pointer; } .img-wrap:hover img { -webkit-transform: translateY(-5px); -moz-transform: translateY(-5px); -ms-transform: translateY(-5px); transform: translateY(-5px); } .img-wrap img { width: 100%; height: 100%; border: 0; -webkit-transition: -webkit-transform .4s ease; transition: -webkit-transform .4s ease; -moz-transition: transform .4s ease,-moz-transform .4s ease; transition: transform .4s ease; transition: transform .4s ease,-webkit-transform .4s ease,-moz-transform .4s ease; -webkit-transform: translateY(0); -moz-transform: translateY(0); -ms-transform: translateY(0); transform: translateY(0); } </style> </head> <body> <a class="img-wrap" href="javascript:;"> <img alt="" src="http://p3.pstatp.com/list/640x360/11ff00027e781c4f7807"> </a> </body> </html>
向左移動:
將上面CSS樣式改成下面即可:
body{ padding: 4rem; } .img-wrap { width: 194px; height: 108px; display: block; cursor: pointer; } .img-wrap:hover img { -webkit-transform: translateX(-5px); -moz-transform: translateX(-5px); -ms-transform: translateX(-5px); transform: translateX(-5px); } .img-wrap img { width: 100%; height: 100%; border: 0; -webkit-transition: -webkit-transform .4s ease; transition: -webkit-transform .4s ease; -moz-transition: transform .4s ease,-moz-transform .4s ease; transition: transform .4s ease; transition: transform .4s ease,-webkit-transform .4s ease,-moz-transform .4s ease; -webkit-transform: translateX(0); -moz-transform: translateX(0); -ms-transform: translateX(0); transform: translateX(0); }
晃動的計算器圖示
程式碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>animation</title> <style> body{ padding: 4rem; } .calculator{ margin: -35px auto 30px; width: 150px; line-height: 30px; text-align: center; border: 1px solid #ff7200; -webkit-border-radius: 30px; -moz-border-radius: 30px; border-radius: 30px; cursor: pointer; font-size: 0; } .calculator:hover{ background-color: #fb7b14; } .calculator i{ display: inline-block; width: 12px; height: 16px; line-height: 1; margin-right: 10px; vertical-align: middle; background: url("cal.png") no-repeat; } .calculator i.tada{ -webkit-animation: tada 2s infinite linear; -moz-animation: tada 2s infinite linear; animation: tada 2s infinite linear; } .calculator .calculator-txt{ line-height: 1; vertical-align: middle; color: #ff7200; font-size: 14px; } .calculator:hover .calculator-txt{ color: #fff; } .calculator:hover i{ background-position: 0 -16px; } .calculator:hover i.tada{ -webkit-animation: ccc 2s infinite; -moz-animation: ccc 2s infinite; animation: ccc 2s infinite; } @keyframes tada{ 0% { -webkit-transform: none; -moz-transform: none; transform: none; } 5% { -webkit-transform: translate3d(-25%,0,0) rotate3d(0,0,1,-5deg); -moz-transform: translate3d(-25%,0,0) rotate3d(0,0,1,-5deg); transform: translate3d(-25%,0,0) rotate3d(0,0,1,-5deg); } 10% { -webkit-transform: translate3d(20%,0,0) rotate3d(0,0,1,3deg); -moz-transform: translate3d(20%,0,0) rotate3d(0,0,1,3deg); transform: translate3d(20%,0,0) rotate3d(0,0,1,3deg); } 15% { -webkit-transform: translate3d(-15%,0,0) rotate3d(0,0,1,-3deg); -moz-transform: translate3d(-15%,0,0) rotate3d(0,0,1,-3deg); transform: translate3d(-15%,0,0) rotate3d(0,0,1,-3deg); } 20% { -webkit-transform: translate3d(10%,0,0) rotate3d(0,0,1,2deg); -moz-transform: translate3d(10%,0,0) rotate3d(0,0,1,2deg); transform: translate3d(10%,0,0) rotate3d(0,0,1,2deg); } 25%, 26% { -webkit-transform: translate3d(-5%,0,0) rotate3d(0,0,1,-1deg); -moz-transform: translate3d(-5%,0,0) rotate3d(0,0,1,-1deg); transform: translate3d(-5%,0,0) rotate3d(0,0,1,-1deg); } 100% { -webkit-transform: none; -moz-transform: none; transform: none; } } </style> </head> <body> <div class="calculator"> <i class="tada"></i><span class="calculator-txt">省錢計算器</span> </div> </body> </html>
轉動的地球
程式碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Global</title> <style tyle="text/css"> body { background-color: #111; } #earth { width: 300px; height: 300px; background: url(http://users.evtek.fi/~sampsara/3D/Earth-Spec4096.jpg); border-radius: 50%; background-size: 610px; box-shadow: inset 8px 36px 80px 36px rgb(0, 0, 0), inset -6px 0 12px 4px rgba(255, 255, 255, 0.3); animation-name: rotate; animation-duration: 12s; animation-iteration-count: infinite; animation-timing-function: linear; -webkit-animation-name: rotate; -webkit-animation-duration: 12s; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; } @keyframes rotate { from { background-position: 0px 0px; } to { background-position: 610px 0px; } } @-webkit-keyframes rotate { from { background-position: 0px 0px; } to { background-position: 610px 0px; } } </style> </head> <body> <div id="earth"></div> </body> </html>
點贊效果
程式碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>like</title> <style type="text/css"> img{ /*width: 20px; height: 20px;*/ position: absolute; bottom: 100px; left: 50%; margin-left: -12.5px; } .btn{ width: 100px; height: 30px; border:0; background: red; color: #fff; position: absolute; bottom: 100px; left: 50%; margin-left: -50px; } </style> <script src="jquery.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function(){ $("#btn1").on(`click`, function(){ $(".demo").append("<img src=`love-r.png`>"); $("img").animate({ bottom:"200px", width: "50px", marginLeft: "-25px", opacity:"0" }, 1000, function(){ $(".demo").empty(); }); }); }); </script> </head> <body> <div class="demo"></div> <input id="btn1" type="button" class="btn" value="點贊"> </body> </html>
本文轉自Jaxu部落格園部落格,原文連結:http://www.cnblogs.com/jaxu/p/5946947.html,如需轉載請自行聯絡原作者
相關文章
- GO面試題集錦快答[持續更新]Go面試題
- pip安裝時遇到的問題集錦,持續更新!
- Flutter 問題集,持續更新Flutter
- 《CSS世界》閱讀筆記,持續更新CSS筆記
- git使用、持續更新中Git
- JVM(持續更新。。。)JVM
- FastApi持續更新ASTAPI
- 彙編筆記(持續更新中)筆記
- Spring面試題(持續更新中)Spring面試題
- JiaoZiVideoPlayer使用說明(持續更新中...)IDE
- clion小白使用技巧(持續更新中)
- 常見 git 需求整理(持續更新中)Git
- springMVC簡單demo集合(持續更新中……)SpringMVC
- 【 一些網址,持續更新中….. 】
- 日常工作筆記(持續更新中。。)筆記
- 個人前端資源彙集(吐血整理 / 持續更新)前端
- Blender 雕刻 持續更新
- Xcode 技巧 持續更新XCode
- android高階頁面效果集錦Android
- arcgis pro2.3教程與問題集持續更新(一)
- PC端寶藏軟體--持續更新中
- PHP面試題總結-持續更新中PHP面試題
- Angular核心概念一覽表(持續更新中)Angular
- C++知識點 —— 整合(持續更新中)C++
- 每天一個linux命令--持續更新中~~Linux
- 元件形式來分析 Laravel 思想 持續更新中元件Laravel
- mysql sql 中實戰小技巧持續更新MySql
- Dom中高big 事件總結(持續更新中)事件
- LeetCode演算法系列,持續更新中...LeetCode演算法
- CentOS 7 常用命令 (持續更新中...)CentOS
- AnimalController 學習 持續更新Controller
- LevOJ平臺 - 持續更新
- idea快捷鍵(持續更新)Idea
- MySql報錯(持續更新)MySql
- LINUX進階(持續更新)Linux
- Pycharm快捷鍵持續更新PyCharm
- leetcode題解【持續更新】LeetCode
- Java工程師常見面試題集錦(三)網際網路人必看!(附答案及視訊教程,持續更新!)Java工程師面試題
- Java工程師常見面試題集錦(二)網際網路人必看!(附答案及視訊教程,持續更新)Java工程師面試題