0

0

css3 animation 学习_html/css_WEB-ITnose

php中文网

php中文网

发布时间:2016-06-24 11:53:42

|

1525人浏览过

|

来源于php中文网

原创

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

 

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

 

下面是效果图:

立即学习前端免费学习笔记(深入)”;

 

 

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

Q.AI视频生成工具
Q.AI视频生成工具

支持一分钟生成专业级短视频,多种生成方式,AI视频脚本,在线云编辑,画面自由替换,热门配音媲美真人音色,更多强大功能尽在QAI

下载

 

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.                 
  
  •                   
  •             
  •   
  •               
  •         
  •   
  •   
  •   
  •  

    相关文章

    HTML速学教程(入门课程)
    HTML速学教程(入门课程)

    HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

    下载

    本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

    热门AI工具

    更多
    DeepSeek
    DeepSeek

    幻方量化公司旗下的开源大模型平台

    豆包大模型
    豆包大模型

    字节跳动自主研发的一系列大型语言模型

    通义千问
    通义千问

    阿里巴巴推出的全能AI助手

    腾讯元宝
    腾讯元宝

    腾讯混元平台推出的AI助手

    文心一言
    文心一言

    文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

    讯飞写作
    讯飞写作

    基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

    即梦AI
    即梦AI

    一站式AI创作平台,免费AI图片和视频生成。

    ChatGPT
    ChatGPT

    最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

    相关专题

    更多
    Golang 并发编程模型与工程实践:从语言特性到系统性能
    Golang 并发编程模型与工程实践:从语言特性到系统性能

    本专题系统讲解 Golang 并发编程模型,从语言级特性出发,深入理解 goroutine、channel 与调度机制。结合工程实践,分析并发设计模式、性能瓶颈与资源控制策略,帮助将并发能力有效转化为稳定、可扩展的系统性能优势。

    2

    2026.02.27

    Golang 高级特性与最佳实践:提升代码艺术
    Golang 高级特性与最佳实践:提升代码艺术

    本专题深入剖析 Golang 的高级特性与工程级最佳实践,涵盖并发模型、内存管理、接口设计与错误处理策略。通过真实场景与代码对比,引导从“可运行”走向“高质量”,帮助构建高性能、可扩展、易维护的优雅 Go 代码体系。

    1

    2026.02.27

    Golang 测试与调试专题:确保代码可靠性
    Golang 测试与调试专题:确保代码可靠性

    本专题聚焦 Golang 的测试与调试体系,系统讲解单元测试、表驱动测试、基准测试与覆盖率分析方法,并深入剖析调试工具与常见问题定位思路。通过实践示例,引导建立可验证、可回归的工程习惯,从而持续提升代码可靠性与可维护性。

    0

    2026.02.27

    漫蛙app官网链接入口
    漫蛙app官网链接入口

    漫蛙App官网提供多条稳定入口,包括 https://manwa.me、https

    56

    2026.02.27

    deepseek在线提问
    deepseek在线提问

    本合集汇总了DeepSeek在线提问技巧与免登录使用入口,助你快速上手AI对话、写作、分析等功能。阅读专题下面的文章了解更多详细内容。

    4

    2026.02.27

    AO3官网直接进入
    AO3官网直接进入

    AO3官网最新入口合集,汇总2026年可用官方及镜像链接,助你快速稳定访问Archive of Our Own平台。阅读专题下面的文章了解更多详细内容。

    53

    2026.02.27

    php框架基础教程
    php框架基础教程

    本合集涵盖2026年最新PHP框架入门知识与基础教程,适合初学者快速掌握主流框架核心概念与使用方法。阅读专题下面的文章了解更多详细内容。

    1

    2026.02.27

    php框架怎么用
    php框架怎么用

    本合集专为零基础学习者打造,系统介绍主流PHP框架的安装、配置与基础用法,助你快速入门Web开发。阅读专题下面的文章了解更多详细内容。

    4

    2026.02.27

    无禁词AI聊天软件下载大全
    无禁词AI聊天软件下载大全

    本合集精选多款免费、无违禁词限制的AI聊天软件,支持自定义角色、剧情畅聊,体验真实互动感。阅读专题下面的文章了解更多详细内容。

    19

    2026.02.27

    热门下载

    更多
    网站特效
    /
    网站源码
    /
    网站素材
    /
    前端模板

    相关下载

    更多

    精品课程

    更多
    相关推荐
    /
    热门推荐
    /
    最新课程
    Node.js 教程
    Node.js 教程

    共57课时 | 12.3万人学习

    CSS3 教程
    CSS3 教程

    共18课时 | 6.3万人学习

    Rust 教程
    Rust 教程

    共28课时 | 6.4万人学习

    最新文章

    更多
    关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送

    Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号