這次帶給大家簡易的CSS3點選回應動畫案列,使用CSS3製作點擊回應動畫的注意事項有哪些,以下就是實戰案例,一起來看一下。
<html> <head> <style> label{ margin: 0 auto} /*1*/ #che1 { position: relative; border: 2px #666 solid; cursor: pointer; border-radius: 50%; display: block; width: 24px; height: 24px; } #che1 input[type="checkbox"] +div { position: absolute; width: 100%; height: 100%; transition: all 0.2s; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; /* Firefox 4 */ -o-transition: all 0.2s; /* Opera */ transform: rotate(135deg); -ms-transform: rotate(135deg); /* IE 9 */ -webkit-transform: rotate(135deg); /* Safari and Chrome */ -o-transform: rotate(135deg); /* Opera */ -moz-transform: rotate(135deg); } #che1 input[type="checkbox"] +div>div { position: absolute; width: 18px; height: 4px; background: #333; top: 42%; left: 14%; } #che1 input[type="checkbox"] +div>div:nth-child(1) { transform: rotate(45deg); } #che1 input[type="checkbox"] +div>div:nth-child(2) { transform: rotate(-45deg); } #che1 input[type="checkbox"] { display: none; } #che1 input[type="checkbox"]:checked+div { transform: rotate(0deg); -ms-transform: rotate(0deg); /* IE 9 */ -webkit-transform: rotate(0deg); /* Safari and Chrome */ -o-transform: rotate(0deg); /* Opera */ -moz-transform: rotate(0deg); } /*2*/ #che2 { text-align: center; border: 1px #666 solid; cursor: pointer; border-radius: 50%; display: block; width: 20px; height: 20px; } #che2 input[type="checkbox"] { display: none; } #che2 input[type="checkbox"]+ div { color: #fff; width: 100%; height: 100%; border-radius: 50%; background-color: rgba(0, 0, 0, 0.8); -webkit-transition-duration: 0.4s; -webkit-transition-property: background-color, transform; transform: rotate(0deg); -webkit-transform: rotate(0deg); } #che2 input[type="checkbox"]:checked + div { -webkit-transform: rotate(-180deg); -moz-transform: rotate(-180deg); background-color: rgb(204, 204, 204); color: #555; } /*3*/ #che3 { cursor: pointer; display: block; width: 26px; height: 26px; } #che3 input[type="checkbox"] { display: none; }#che3 input[type="checkbox"]+ div { display: block; width: 0; height: 0; border-top: 15px solid transparent; border-bottom: 15px solid transparent; border-left: 25px solid #666; transition: all 0.2s; -webkit-transition: all 0.2s; -moz-transition: all 0.2s; /* Firefox 4 */ -o-transition: all 0.2s; /* Opera */ } #che3 input[type="checkbox"]:checked + div { -webkit-transform: rotateY(-180deg); -moz-transform: rotateY(-180deg); } /*4*/ #che4 { cursor: pointer; display: block; width: 20px; height: 26px; position: relative; } #che4 input[type="checkbox"] { display: none; } #che4 > div { cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che4 input[type="checkbox"]+ div { top: 3px; left: 2px; transform: rotate(-45deg) ; -ms-transform: rotate(-45deg) ; /* IE 9 */ -webkit-transform: rotate(-45deg) ; /* Safari and Chrome */ -o-transform: rotate(-45deg) ; /* Opera */ -moz-transform: rotate(-45deg) ; /* Firefox */ } #che4 input[type="checkbox"]+ div+ div{ top: 16px; left: 2px; transform: rotate(45deg) ; -ms-transform: rotate(45deg) ; /* IE 9 */ -webkit-transform: rotate(45deg) ; /* Safari and Chrome */ -o-transform: rotate(45deg) ; /* Opera */ -moz-transform: rotate(45deg) ; /* Firefox */ } #che4 input[type="checkbox"]:checked+ div { transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); -ms-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* IE 9 */ -webkit-transform: rotate(45deg) ; /* Safari and Chrome */ -o-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Opera */ -moz-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Firefox */ } #che4 input[type="checkbox"]:checked+ div+ div { transform: rotate(-45deg) ; -ms-transform: rotate(-45deg) ; /* IE 9 */ -webkit-transform: rotate(-45deg) ; /* Safari and Chrome */ -o-transform: rotate(-45deg) ; /* Opera */ -moz-transform: rotate(-45deg) ; /* Firefox */ } /*5*/ #che5 { cursor: pointer; display: block; width: 24px; height: 24px; position: relative; } #che5 input[type="checkbox"] { display: none; } #che5 input[type="checkbox"]+ div { width: 100%; height: 100%; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che5 input[type="checkbox"]+ div>div { cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che5 input[type="checkbox"]+ div>div:nth-child(1) { top: 3px; left: 2px; } #che5 input[type="checkbox"]+ div> div:nth-child(2) { top: 10px; left: 2px; } #che5 input[type="checkbox"]+ div> div:nth-child(3) { top: 17px; left: 2px; } #che5 input[type="checkbox"]:checked+ div { transform: rotate(360deg); -ms-transform: rotate(360deg); /* IE 9 */ -webkit-transform: rotate(360deg); /* Safari and Chrome */ -o-transform: rotate(360deg); /* Opera */ -moz-transform: rotate(360deg); } #che5 input[type="checkbox"]:checked+ div>div:nth-child(1) { top: 10px; left: 2px; transform: rotate(45deg); -ms-transform: rotate(45deg); /* IE 9 */ -webkit-transform: rotate(45deg); /* Safari and Chrome */ -o-transform: rotate(45deg); /* Opera */ -moz-transform: rotate(45deg); /* Firefox */ } #che5 input[type="checkbox"]:checked+ div>div:nth-child(2) { transform: scale( 0, 1); -ms-transform: scale( 0, 1); /* IE 9 */ -webkit-transform: scale( 0, 1); /* Safari and Chrome */ -o-transform: scale( 0, 1); /* Opera */ -moz-transform: scale( 0, 1); /* Firefox */ } #che5 input[type="checkbox"]:checked+ div>div:nth-child(3) { top: 10px; left: 2px; transform: rotate(-45deg); -ms-transform: rotate(-45deg); /* IE 9 */ -webkit-transform: rotate(-45deg); /* Safari and Chrome */ -o-transform: rotate(-45deg); /* Opera */ -moz-transform: rotate(-45deg) /* Firefox */ } /*6*/ #che6 { cursor: pointer; display: block; width: 24px; height: 24px; position: relative; } #che6 input[type="checkbox"] { display: none; } #che6 > div { cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che6 input[type="checkbox"]+ div { top: 3px; left: 2px; } #che6 input[type="checkbox"]+ div+ div { top: 10px; left: 2px; } #che6 input[type="checkbox"]+ div+ div+ div { top: 17px; left: 2px; } #che6 input[type="checkbox"]:checked+ div { top: 10px; left: 2px; transform: rotate(45deg); -ms-transform: rotate(45deg); /* IE 9 */ -webkit-transform: rotate(45deg); /* Safari and Chrome */ -o-transform: rotate(45deg); /* Opera */ -moz-transform: rotate(45deg); /* Firefox */ } #che6 input[type="checkbox"]:checked+ div+div { transform: scale( 0, 1); -ms-transform: scale( 0, 1); /* IE 9 */ -webkit-transform: scale( 0, 1); /* Safari and Chrome */ -o-transform: scale( 0, 1); /* Opera */ -moz-transform: scale( 0, 1); /* Firefox */ } #che6 input[type="checkbox"]:checked+ div+ div+ div { top: 10px; left: 2px; transform: rotate(-45deg); -ms-transform: rotate(-45deg); /* IE 9 */ -webkit-transform: rotate(-45deg); /* Safari and Chrome */ -o-transform: rotate(-45deg); /* Opera */ -moz-transform: rotate(-45deg) /* Firefox */ } /*7*/ #che7 { cursor: pointer; display: block; width: 24px; height: 24px; position: relative; } #che7 input[type="checkbox"] { display: none; } #che7 > div { cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che7 input[type="checkbox"]+ div { top: 3px; left: 2px; } #che7 input[type="checkbox"]+ div+ div { top: 10px; left: 2px; } #che7 input[type="checkbox"]+ div+ div+ div { top: 17px; left: 2px; } #che7 input[type="checkbox"]:checked+ div { transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); -ms-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* IE 9 */ -webkit-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Safari and Chrome */ -o-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Opera */ -moz-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Firefox */ } #che7 input[type="checkbox"]:checked+ div+ div+ div { transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); -ms-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* IE 9 */ -webkit-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Safari and Chrome */ -o-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Opera */ -moz-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Firefox */ } /*8*/ #che8 { cursor: pointer; display: block; width: 24px; height: 24px; position: relative; } #che8 input[type="checkbox"] { display: none; } #che8 input[type="checkbox"]+ div { position: absolute; width: 100%; height: 100%; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che8 input[type="checkbox"]+ div> div { position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che8 input[type="checkbox"]+ div>div:nth-child(1) { top: 3px; left: 2px; } #che8 input[type="checkbox"]+ div> div:nth-child(2) { top: 10px; left: 2px; } #che8 input[type="checkbox"]+ div> div:nth-child(3) { top: 17px; left: 2px; } #che8 input[type="checkbox"]:checked+div { transform: rotate(180deg); -ms-transform: rotate(180deg); /* IE 9 */ -webkit-transform: rotate(180deg); /* Safari and Chrome */ -o-transform: rotate(180deg); /* Opera */ -moz-transform: rotate(180deg); } #che8 input[type="checkbox"]:checked+ div> div:nth-child(1) { transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); -ms-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* IE 9 */ -webkit-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Safari and Chrome */ -o-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Opera */ -moz-transform: rotate(45deg) scale(0.7, 1) translate(9px, -3px); /* Firefox */ } #che8 input[type="checkbox"]:checked+ div> div:nth-child(3) { transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); -ms-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* IE 9 */ -webkit-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Safari and Chrome */ -o-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Opera */ -moz-transform: rotate(-45deg) scale(0.7, 1) translate(9px, 3px); /* Firefox */ } /*9*/ #che9 { cursor: pointer; display: block; width: 20px; height: 20px; position: relative; } #che9 input[type="checkbox"] { display: none; } #che9 input[type="checkbox"]+ div { width: 100%; height: 100%; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che9 input[type="checkbox"]+ div>div { top: 10px; left: 2px; cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che9 input[type="checkbox"]+ div>div:nth-child(1) { transform: rotate(45deg); -ms-transform: rotate(45deg); /* IE 9 */ -webkit-transform: rotate(45deg); /* Safari and Chrome */ -o-transform: rotate(45deg); /* Opera */ -moz-transform: rotate(45deg); /* Firefox */ } #che9 input[type="checkbox"]+ div> div:nth-child(2) { transform: rotate(-45deg); -ms-transform: rotate(-45deg); /* IE 9 */ -webkit-transform: rotate(-45deg); /* Safari and Chrome */ -o-transform: rotate(-45deg); /* Opera */ -moz-transform: rotate(-45deg) /* Firefox */ } #che9 input[type="checkbox"]:checked+ div { transform: rotate(360deg); -ms-transform: rotate(360deg); /* IE 9 */ -webkit-transform: rotate(360deg); /* Safari and Chrome */ -o-transform: rotate(360deg); /* Opera */ -moz-transform: rotate(360deg); } #che9 input[type="checkbox"]:checked+ div>div:nth-child(1) { top: 13px; left: 3px; width: 10px; transform: rotate(30deg); -ms-transform: rotate(30deg); /* IE 9 */ -webkit-transform: rotate(30deg); /* Safari and Chrome */ -o-transform: rotate(30deg); /* Opera */ -moz-transform: rotate(30deg); /* Firefox */ } #che9 input[type="checkbox"]:checked+ div>div:nth-child(2) { top: 10px; left:8px; width: 18px; transform: rotate(-60deg); -ms-transform: rotate(-60deg); /* IE 9 */ -webkit-transform: rotate(-60deg); /* Safari and Chrome */ -o-transform: rotate(-60deg); /* Opera */ -moz-transform: rotate(-60deg); } /*10*/ #che10 { cursor: pointer; display: block; width: 20px; height: 20px; position: relative; } #che10 input[type="checkbox"] { display: none; } #che10 input[type="checkbox"]+ div { width: 100%; height: 100%; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che10 input[type="checkbox"]+ div>div { top: 10px; left: 2px; cursor: pointer; position: absolute; width: 20px; height: 3px; background: #333; transition: all 0.26s; -moz-transition: all 0.26s; /* Firefox 4 */ -webkit-transition: all 0.26s; /* Safari 和 Chrome */ -o-transition: all 0.26s; } #che10 input[type="checkbox"]+ div>div:nth-child(1) { transform: rotate(45deg); -ms-transform: rotate(45deg); /* IE 9 */ -webkit-transform: rotate(45deg); /* Safari and Chrome */ -o-transform: rotate(45deg); /* Opera */ -moz-transform: rotate(45deg); /* Firefox */ } #che10 input[type="checkbox"]+ div> div:nth-child(2) { transform: rotate(-45deg); -ms-transform: rotate(-45deg); /* IE 9 */ -webkit-transform: rotate(-45deg); /* Safari and Chrome */ -o-transform: rotate(-45deg); /* Opera */ -moz-transform: rotate(-45deg) /* Firefox */ } #che10 input[type="checkbox"]:checked+ div { /*transform: rotate(360deg); -ms-transform: rotate(360deg); IE 9 */ /*-webkit-transform: rotate(360deg); Safari and Chrome */ /*-o-transform: rotate(360deg); Opera -moz-transform: rotate(360deg);*/ } #che10 input[type="checkbox"]:checked+ div>div:nth-child(1) { top: 13px; left: 3px; width: 10px; transform: rotate(30deg); -ms-transform: rotate(30deg); /* IE 9 */ -webkit-transform: rotate(30deg); /* Safari and Chrome */ -o-transform: rotate(30deg); /* Opera */ -moz-transform: rotate(30deg); /* Firefox */ } #che10 input[type="checkbox"]:checked+ div>div:nth-child(2) { top: 10px; left:8px; width: 18px; transform: rotate(-60deg); -ms-transform: rotate(-60deg); /* IE 9 */ -webkit-transform: rotate(-60deg); /* Safari and Chrome */ -o-transform: rotate(-60deg); /* Opera */ -moz-transform: rotate(-60deg); } </style> </head> <body> <label id="che1"> <input type="checkbox" /> <div> <div></div> <div></div> </div> </label> <br /> <label id="che2"> <input type="checkbox" /> <div>></div> </label> <br /> <label id="che3"> <input type="checkbox" /> <div></div> </label> <br /> <label id="che4"> <input type="checkbox" /> <div></div> <div></div> </label> <br /> <label id="che5"> <input type="checkbox" /> <div> <div></div> <div></div> <div></div> </div> </label> <br /> <label id="che6"> <input type="checkbox" /> <div></div> <div></div> <div></div> </label> <br /> <label id="che7"> <input type="checkbox" /> <div></div> <div></div> <div></div> </label> <br /> <label id="che8"> <input type="checkbox" /> <div> <div></div> <div></div> <div></div> </div> </label> <br /> <label id="che9"> <input type="checkbox" /> <div> <div></div> <div></div> </div> </label> <br /> <label id="che10"> <input type="checkbox" /> <div> <div></div> <div></div> </div> </label> </body> </html>
我相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!
相關閱讀:
以上是簡易的CSS3點擊響應動畫案列的詳細內容。更多資訊請關注PHP中文網其他相關文章!

JavaScript是現代網站的核心,因為它增強了網頁的交互性和動態性。 1)它允許在不刷新頁面的情況下改變內容,2)通過DOMAPI操作網頁,3)支持複雜的交互效果如動畫和拖放,4)優化性能和最佳實踐提高用戶體驗。

C 和JavaScript通過WebAssembly實現互操作性。 1)C 代碼編譯成WebAssembly模塊,引入到JavaScript環境中,增強計算能力。 2)在遊戲開發中,C 處理物理引擎和圖形渲染,JavaScript負責遊戲邏輯和用戶界面。

JavaScript在網站、移動應用、桌面應用和服務器端編程中均有廣泛應用。 1)在網站開發中,JavaScript與HTML、CSS一起操作DOM,實現動態效果,並支持如jQuery、React等框架。 2)通過ReactNative和Ionic,JavaScript用於開發跨平台移動應用。 3)Electron框架使JavaScript能構建桌面應用。 4)Node.js讓JavaScript在服務器端運行,支持高並發請求。

Python更適合數據科學和自動化,JavaScript更適合前端和全棧開發。 1.Python在數據科學和機器學習中表現出色,使用NumPy、Pandas等庫進行數據處理和建模。 2.Python在自動化和腳本編寫方面簡潔高效。 3.JavaScript在前端開發中不可或缺,用於構建動態網頁和單頁面應用。 4.JavaScript通過Node.js在後端開發中發揮作用,支持全棧開發。

C和C 在JavaScript引擎中扮演了至关重要的角色,主要用于实现解释器和JIT编译器。1)C 用于解析JavaScript源码并生成抽象语法树。2)C 负责生成和执行字节码。3)C 实现JIT编译器,在运行时优化和编译热点代码,显著提高JavaScript的执行效率。

JavaScript在現實世界中的應用包括前端和後端開發。 1)通過構建TODO列表應用展示前端應用,涉及DOM操作和事件處理。 2)通過Node.js和Express構建RESTfulAPI展示後端應用。

JavaScript在Web開發中的主要用途包括客戶端交互、表單驗證和異步通信。 1)通過DOM操作實現動態內容更新和用戶交互;2)在用戶提交數據前進行客戶端驗證,提高用戶體驗;3)通過AJAX技術實現與服務器的無刷新通信。

理解JavaScript引擎內部工作原理對開發者重要,因為它能幫助編寫更高效的代碼並理解性能瓶頸和優化策略。 1)引擎的工作流程包括解析、編譯和執行三個階段;2)執行過程中,引擎會進行動態優化,如內聯緩存和隱藏類;3)最佳實踐包括避免全局變量、優化循環、使用const和let,以及避免過度使用閉包。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

禪工作室 13.0.1
強大的PHP整合開發環境

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3漢化版
中文版,非常好用

Atom編輯器mac版下載
最受歡迎的的開源編輯器