搜尋
首頁web前端html教學css3 animation 学习_html/css_WEB-ITnose

css3中可以实现动画效果,主要是通过css3中新增加的属性(transform , transition,animation )来完成。

 

他们的详细解释可以参考 W3CSCHOOL

 

下面是效果图:

 

 

类似于tab选项卡,当点击某个input的时候,就以动画的效果来显示对应的内容区域。

 

Html代码   

  1.   
  2.   
  3.       
  4.        
  5.   
  6.       
  7. body{  
  8.     overflow: hidden;  
  9. }  
  10.   
  11. .st-container {  
  12.     position: absolute;  
  13.     width: 100%;  
  14.     height: 100%;  
  15.     top: 0;  
  16.     left: 0;  
  17.     font-family: Arial, sans-serif;  
  18. }  
  19.   
  20. /*put the “navigation” at the top of the page by giving it a fixed position*/  
  21.   
  22. .st-container > input,  
  23. .st-container > a {  
  24.     position: fixed;  
  25.     top: 0;  
  26.     width: 20%;  
  27.     cursor: pointer;  
  28.     font-size: 16px;  
  29.     height: 34px;  
  30.     line-height: 34px;  
  31. }  
  32.    
  33. .st-container > input {  
  34.     opacity: 0;  
  35.     z-index: 1000;  
  36. }  
  37.    
  38. .st-container > a {  
  39.     z-index: 10;  
  40.     font-weight: 700;  
  41.     background: #e23a6e;  
  42.     color: #fff;  
  43.     text-align: center;  
  44.     text-shadow: 1px 1px 1px rgba(151,24,64,0.2);  
  45.     text-decoration: none;  
  46. }  
  47.   
  48. /*It will have the same background color like the link elements:*/  
  49. .st-container:after {  
  50.     content: '';  
  51.     position: fixed;  
  52.     width: 100%;  
  53.     height: 34px;  
  54.     background: #e23a6e;  
  55.     z-index: 9;  
  56.     top: 0;  
  57. }  
  58.   
  59. /*give input and links  respective left values*/  
  60. #st-control-1, #st-control-1 + a {  
  61.     left: 0;  
  62. }  
  63.    
  64. #st-control-2, #st-control-2 + a {  
  65.     left: 20%;  
  66. }  
  67.    
  68. #st-control-3, #st-control-3 + a {  
  69.     left: 40%;  
  70. }  
  71.    
  72. #st-control-4, #st-control-4 + a {  
  73.     left: 60%;  
  74. }  
  75.    
  76. #st-control-5, #st-control-5 + a {  
  77.     left: 80%;  
  78. }  
  79.   
  80. /*define a “selected” state for the link elements.*/  
  81. .st-container > input:checked + a,  
  82. .st-container > input:checked:hover + a{  
  83.     background: #821134;  
  84. }  
  85.   
  86. /*add a little triangle using the pseudo-class :after and give it the same color:*/  
  87.   
  88. .st-container > input:checked + a:after,  
  89. .st-container > input:checked:hover + a:after{  
  90.     top: 100%;  
  91.     border: solid transparent;  
  92.     content: '';  
  93.     height: 0;  
  94.     width: 0;  
  95.     position: absolute;  
  96.     pointer-events: none;  
  97.     border-top-color: #821134;  
  98.     border-width: 20px;  
  99.     left: 50%;  
  100.     margin-left: -20px;  
  101. }  
  102.   
  103. /*define a hover state for the link element:*/  
  104. .st-container > input:hover + a{  
  105.     background: #AD244F;  
  106. }  
  107.    
  108. .st-container > input:hover + a:after {  
  109.     border-bottom-color: #AD244F;  
  110. }  
  111.   
  112. /*define scroll panel style*/  
  113.   
  114. .st-scroll,  
  115. .st-panel {  
  116.     position: relative;  
  117.     width: 100%;  
  118.     height: 100%;  
  119. }  
  120.    
  121. .st-scroll {  
  122.     top: 0;  
  123.     left: 0;  
  124.     -webkit-transition: all 0.6s ease-in-out;  
  125.        
  126.     /* Let's enforce some hardware acceleration */  
  127.     -webkit-transform: translate3d(0, 0, 0);  
  128.     -webkit-backface-visibility: hidden;  
  129.     border: solid 1px #ccc;  
  130. }  
  131.    
  132. .st-panel{  
  133.     background: #fff;  
  134.     overflow: hidden;  
  135. }   
  136.   
  137. /**define the positions for the st-scroll wrapper for each checked radio button*/  
  138.   
  139. #st-control-1:checked ~ .st-scroll {  
  140.     -webkit-transform: translateY(0%);  
  141.     background-color: green;  
  142. }  
  143. #st-control-2:checked ~ .st-scroll {  
  144.     -webkit-transform: translateY(-100%);  
  145.     background-color: green;  
  146. }  
  147. #st-control-3:checked ~ .st-scroll {  
  148.     -webkit-transform: translateY(-200%);  
  149.     background-color: green;  
  150. }  
  151. #st-control-4:checked ~ .st-scroll {  
  152.     -webkit-transform: translateY(-300%);  
  153.     background-color: green;  
  154. }  
  155. #st-control-5:checked ~ .st-scroll {  
  156.     -webkit-transform: translateY(-400%);  
  157.     background-color: green;  
  158. }  
  159.   
  160. #st-control-1:checked ~ .st-scroll #st-panel-1 h2,  
  161. #st-control-2:checked ~ .st-scroll #st-panel-2 h2,  
  162. #st-control-3:checked ~ .st-scroll #st-panel-3 h2,  
  163. #st-control-4:checked ~ .st-scroll #st-panel-4 h2,  
  164. #st-control-5:checked ~ .st-scroll #st-panel-5 h2{  
  165.     -webkit-animation: moveDown 1.6s ease-in-out 1.2s backwards;  
  166. }  
  167.   
  168. /** define animation for the scroll panel*/   
  169. @keyframes moveDown{  
  170.     0% {   
  171.         -webkit-transform: translateY(-40px);   
  172.         opacity: 0;  
  173.     }  
  174.     100% {   
  175.         -webkit-transform: translateY(0px);    
  176.         opacity: 1;  
  177.     }  
  178. }  
  179.   
  180. .st-panel h2 {  
  181.     color: #e23a6e;  
  182.     text-shadow: 1px 1px 1px rgba(151,24,64,0.2);  
  183.     position: absolute;  
  184.     font-size: 54px;  
  185.     font-weight: 900;  
  186.     width: 80%;  
  187.     left: 10%;  
  188.     text-align: center;  
  189.     line-height: 50px;  
  190.     margin: -70px 0 0 0;  
  191.     padding: 0;  
  192.     top: 50%;  
  193.     -webkit-backface-visibility: hidden;  
  194. }  
  195.   
  196. .st-panel p {  
  197.     position: absolute;  
  198.     text-align: center;  
  199.     font-size: 16px;  
  200.     line-height: 22px;  
  201.     color: #8b8b8b;  
  202.     z-index: 2;  
  203.     padding: 0;  
  204.     width: 50%;  
  205.     left: 25%;  
  206.     top: 50%;  
  207.     margin: 10px 0 0 0;  
  208.     -webkit-backface-visibility: hidden;  
  209. }  
  210.   
  211.   
  212.   
  213.         
      
  214.           
  215.             
      
  216.               
  217.                   
  218.                 Serendipity  
  219.                   
  220.                 Happiness  
  221.                   
  222.                 Tranquillity  
  223.                   
  224.                 Positivity  
  225.                   
  226.                 Passion  
  227.                   
  228.                 
      
  229.                   
  230.                       
  231.                       
  232.                     
      
  233.                         

    Serendipity

      
  234.                         

    Banksy adipisicing eiusmod banh mi sed. Squid stumptown est odd future nisi, commodo mlkshk pop-up adipisicing retro.

      
  235.                       
  236.                       
  237.                     
      
  238.                         

    Happiness

      
  239.                         

    Art party readymade beard labore cosby sweater culpa. Art party whatever incididunt, scenester umami polaroid tofu.

      
  240.                       
  241.                       
  242.                     
      
  243.                         

    Tranquillity

      
  244.                         

    Sint aute occaecat id vice. Post-ironic fap pork belly next level godard, id fanny pack williamsburg forage truffaut.

      
  245.                       
  246.                       
  247.                     
      
  248.                         

    Positivity

      
  249.                         

    Mixtape fap leggings art party, butcher authentic farm-to-table you probably haven't heard of them do labore cosby sweater.

      
  250.                       
  251.                       
  252.                     
      
  253.                         

    Passion

      
  254.                         

    Fixie ad odd future polaroid dreamcatcher, nesciunt carles bicycle rights accusamus mcsweeney's mumblecore nulla irony.

      
  255.                       
  256.   
  257.                 
  
  •                   
  •             
  •   
  •               
  •         
  •   
  •   
  •   
  •  

    陳述
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    了解HTML,CSS和JavaScript:初學者指南了解HTML,CSS和JavaScript:初學者指南Apr 12, 2025 am 12:02 AM

    WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

    HTML的角色:構建Web內容HTML的角色:構建Web內容Apr 11, 2025 am 12:12 AM

    HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。

    HTML和代碼:仔細觀察術語HTML和代碼:仔細觀察術語Apr 10, 2025 am 09:28 AM

    htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代碼” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代碼”代碼“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

    HTML,CSS和JavaScript:Web開發人員的基本工具HTML,CSS和JavaScript:Web開發人員的基本工具Apr 09, 2025 am 12:12 AM

    HTML、CSS和JavaScript是Web開發的三大支柱。 1.HTML定義網頁結構,使用標籤如、等。 2.CSS控製網頁樣式,使用選擇器和屬性如color、font-size等。 3.JavaScript實現動態效果和交互,通過事件監聽和DOM操作。

    HTML,CSS和JavaScript的角色:核心職責HTML,CSS和JavaScript的角色:核心職責Apr 08, 2025 pm 07:05 PM

    HTML定義網頁結構,CSS負責樣式和佈局,JavaScript賦予動態交互。三者在網頁開發中各司其職,共同構建豐富多彩的網站。

    HTML容易為初學者學習嗎?HTML容易為初學者學習嗎?Apr 07, 2025 am 12:11 AM

    HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。

    HTML中起始標籤的示例是什麼?HTML中起始標籤的示例是什麼?Apr 06, 2025 am 12:04 AM

    AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

    如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?如何利用CSS的Flexbox佈局實現菜單中虛線分割效果的居中對齊?Apr 05, 2025 pm 01:24 PM

    如何設計菜單中的虛線分割效果?在設計菜單時,菜名和價格的左右對齊通常不難實現,但中間的虛線或點如何...

    See all articles

    熱AI工具

    Undresser.AI Undress

    Undresser.AI Undress

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

    AI Clothes Remover

    AI Clothes Remover

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

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Clothoff.io

    Clothoff.io

    AI脫衣器

    AI Hentai Generator

    AI Hentai Generator

    免費產生 AI 無盡。

    熱門文章

    R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
    3 週前By尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O.最佳圖形設置
    3 週前By尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O.如果您聽不到任何人,如何修復音頻
    3 週前By尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25:如何解鎖Myrise中的所有內容
    3 週前By尊渡假赌尊渡假赌尊渡假赌

    熱工具

    Atom編輯器mac版下載

    Atom編輯器mac版下載

    最受歡迎的的開源編輯器

    MantisBT

    MantisBT

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

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    強大的PHP整合開發環境

    EditPlus 中文破解版

    EditPlus 中文破解版

    體積小,語法高亮,不支援程式碼提示功能

    SecLists

    SecLists

    SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。