欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

css3 animation 学习_html/css_WEB-ITnose

程序员文章站 2022-06-16 14:15:38
...
css3中可以实现动画效果,主要是通过css3中新增加的属性(transform , transition,animation )来完成。

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

下面是效果图:

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

Html代码

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

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

  184. Happiness

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

  186. Tranquillity

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

  188. Positivity

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

  190. Passion

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

  • 相关标签: css3 animation 学习

    上一篇: Oracle SMON进程的操作流程

    下一篇: Oracle 用户权限管理方法

    推荐阅读