js和css3實現的扇子展開效果
分享一段程式碼例項,它利用js和css3實現了扇子展開效果。
點選白色的原型圖案就會展開扇子,程式碼例項如下:
[HTML] 純文字檢視 複製程式碼<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <title>螞蟻部落</title> <style> .main { width: 800px; position: relative; height: 500px; top: 50%; left: 50%; margin-top: 200px; } .main div { width: 80px; height: 400px; position: absolute; top: 0; left: 0; border-radius: 10px; -webkit-transform-origin: 25px 360px; } #main1 { background: #DB3535; -webkit-transform: rotate(0deg); z-index: 1; } #main2 { background: #F16729; -webkit-transform: rotate(0deg); z-index: 2; } #main3 { background: #F89424; -webkit-transform: rotate(0deg); z-index: 3; } #main4 { background: #FFCF13; -webkit-transform: rotate(0deg); z-index: 4; } #main5 { background: #FFEA0D; -webkit-transform: rotate(0deg); z-index: 5; } #main6 { background: #87B11F; -webkit-transform: rotate(0deg); z-index: 6; } #main7 { background: #008254; -webkit-transform: rotate(0deg); z-index: 7; } #main8 { background: #3377B6; -webkit-transform: rotate(0deg); z-index: 8; } #main9 { background: #4C549F; -webkit-transform: rotate(0deg); z-index: 9; } #main10 { background: #774395; -webkit-transform: rotate(0deg); z-index: 10; } #main11 { background: #CA0C86; -webkit-transform: rotate(0deg); z-index: 11; } #main12 { background: #FCF27E; -webkit-transform: rotate(0deg); z-index: 12; } #main13 { background: #FFEA0D; -webkit-transform: rotate(0deg); z-index: 13; } #main14 { background: #FFCF13; -webkit-transform: rotate(0deg); z-index: 14; } #main15 { background: #F89424; -webkit-transform: rotate(0deg); z-index: 15; } #main16 { background: #F16729; -webkit-transform: rotate(0deg); z-index: 16; } #main17 { background: #DB3535; -webkit-transform: rotate(0deg); z-index: 17; text-align: center; line-height: 400px; } #main18 { display: block; position: absolute; top: 355px; left: 0; width: 20px; height: 20px; background: #ccc; border-radius: 10px; z-index: 18; } </style> <script> window.onload = function() { var flag = 1; var main18 = document.getElementById('main18'); main18.onclick = function() { if (flag == 1) { main17.style.transition = '-webkit-transform 3s'; main17.style.transform = 'rotate(80deg)'; main16.style.transition = '-webkit-transform 3s'; main16.style.transform = 'rotate(70deg)'; main15.style.transition = '-webkit-transform 3s'; main15.style.transform = 'rotate(60deg)'; main14.style.transition = '-webkit-transform 3s'; main14.style.transform = 'rotate(50deg)'; main13.style.transition = '-webkit-transform 3s'; main13.style.transform = 'rotate(40deg)'; main12.style.transition = '-webkit-transform 3s'; main12.style.transform = 'rotate(30deg)'; main11.style.transition = '-webkit-transform 3s'; main11.style.transform = 'rotate(20deg)'; main10.style.transition = '-webkit-transform 3s'; main10.style.transform = 'rotate(10deg)'; main9.style.transition = '-webkit-transform 3s'; main9.style.transform = 'rotate(0deg)'; main8.style.transition = '-webkit-transform 3s'; main8.style.transform = 'rotate(-10deg)'; main7.style.transition = '-webkit-transform 3s'; main7.style.transform = 'rotate(-20deg)'; main6.style.transition = '-webkit-transform 3s'; main6.style.transform = 'rotate(-30deg)'; main5.style.transition = '-webkit-transform 3s'; main5.style.transform = 'rotate(-40deg)'; main4.style.transition = '-webkit-transform 3s'; main4.style.transform = 'rotate(-50deg)'; main3.style.transition = '-webkit-transform 3s'; main3.style.transform = 'rotate(-60deg)'; main2.style.transition = '-webkit-transform 3s'; main2.style.transform = 'rotate(-70deg)'; main1.style.transition = '-webkit-transform 3s'; main1.style.transform = 'rotate(-80deg)'; flag = 0; } else if (flag == 0) { main17.style.transition = '-webkit-transform 3s'; main17.style.transform = 'rotate(0deg)'; main16.style.transition = '-webkit-transform 3s'; main16.style.transform = 'rotate(0deg)'; main15.style.transition = '-webkit-transform 3s'; main15.style.transform = 'rotate(0deg)'; main14.style.transition = '-webkit-transform 3s'; main14.style.transform = 'rotate(0deg)'; main13.style.transition = '-webkit-transform 3s'; main13.style.transform = 'rotate(0deg)'; main12.style.transition = '-webkit-transform 3s'; main12.style.transform = 'rotate(0deg)'; main11.style.transition = '-webkit-transform 3s'; main11.style.transform = 'rotate(0deg)'; main10.style.transition = '-webkit-transform 3s'; main10.style.transform = 'rotate(0deg)'; main9.style.transition = '-webkit-transform 3s'; main9.style.transform = 'rotate(0deg)'; main8.style.transition = '-webkit-transform 3s'; main8.style.transform = 'rotate(0deg)'; main7.style.transition = '-webkit-transform 3s'; main7.style.transform = 'rotate(0deg)'; main6.style.transition = '-webkit-transform 3s'; main6.style.transform = 'rotate(0deg)'; main5.style.transition = '-webkit-transform 3s'; main5.style.transform = 'rotate(0deg)'; main4.style.transition = '-webkit-transform 3s'; main4.style.transform = 'rotate(0deg)'; main3.style.transition = '-webkit-transform 3s'; main3.style.transform = 'rotate(0deg)'; main2.style.transition = '-webkit-transform 3s'; main2.style.transform = 'rotate(0deg)'; main1.style.transition = '-webkit-transform 3s'; main1.style.transform = 'rotate(0deg)'; flag = 1; } } } </script> </head> <body> <div class="main"> <div id="main1"></div> <div id="main2"></div> <div id="main3"></div> <div id="main4"></div> <div id="main5"></div> <div id="main6"></div> <div id="main7"></div> <div id="main8"></div> <div id="main9"></div> <div id="main10"></div> <div id="main11"></div> <div id="main12"></div> <div id="main13"></div> <div id="main14"></div> <div id="main15"></div> <div id="main16"></div> <div id="main17"></div> <span id="main18"></span> </div> </body> </html>
相關文章
- js和css實現的扇子展開和摺疊效果程式碼例項JSCSS
- js和css3實現能夠展開和摺疊的摺扇效果JSCSSS3
- js和css3實現的空調效果JSCSSS3
- css3和js實現的大白動畫效果CSSS3JS動畫
- js和css3實現的圓形鐘錶效果JSCSSS3
- css3實現的箱子拆開和封裝效果CSSS3封裝
- js和css3實現360旋轉滾動效果JSCSSS3
- css3和javascript實現的時鐘效果CSSS3JavaScript
- jQuery和css3實現的開關效果程式碼例項jQueryCSSS3
- css3和js實現的圓形鐘錶效果程式碼例項CSSS3JS
- jQuery和css3實現的電子錶效果jQueryCSSS3
- 純CSS3實現滑動開關效果CSSS3
- JS和Css實現紅包雨的效果JSCSS
- css3實現翻牌效果CSSS3
- jquery和css3實現的動態時鐘效果jQueryCSSS3
- jQuery和css3實現的摩天輪旋轉效果jQueryCSSS3
- css3實現的矩形切角效果CSSS3
- css3和jQuery實現的點選出現波紋效果CSSS3jQuery
- jquery和css3實現的巴西里約奧運火炬效果jQueryCSSS3
- css3實現的簡單動畫效果CSSS3動畫
- css3實現的紅心跳動效果CSSS3
- js和css3實現的載入等待特效JSCSSS3特效
- jQuery實現的表格展開伸縮效果例項jQuery
- css3實現的旋轉的陀螺效果CSSS3
- js和css3實現的圖片立體滾動切換效果程式碼例項JSCSSS3
- css3實現的文字顏色漸變和漸隱效果CSSS3
- 前端實現彈幕效果的方法總結(包含css3和canvas的實現方式)前端CSSS3Canvas
- css3實現動畫閃爍效果CSSS3動畫
- css3實現元素垂直居中效果CSSS3
- CSS3實現多種背景效果CSSS3
- css3實現的立體滾動效果CSSS3
- CSS3實現多樣的邊框效果CSSS3
- CSS3實現的多重背景效果程式碼CSSS3
- CSS3實現的頁面反轉效果CSSS3
- css3實現的矩形圓角切角效果CSSS3
- css3實現的立方體旋轉效果CSSS3
- css3實現的相機鏡頭效果CSSS3
- js實現打字效果JS