1-1 什么是CSS3?
本节编程练习不计算学习进度,请电脑登录imooc.com操作

什么是CSS3?

CSS3是CSS2的升级版本,3只是版本号,它在CSS2.1的基础上增加了很多强大的新功能。 目前主流浏览器chromesafarifirefoxopera、甚至360都已经支持了CSS3大部分功能了,IE10以后也开始全面支持CSS3了。

在编写CSS3样式时,不同的浏览器可能需要不同的前缀。它表示该CSS属性或规则尚未成为W3C标准的一部分,是浏览器的私有属性,虽然目前较新版本的浏览器都是不需要前缀的,但为了更好的向前兼容前缀还是少不了的。

前缀

浏览器

-webkit

chrome和safari

-moz

firefox

-ms

IE

-o

opera


相信CSS3的时代马上就要到来了!

 

IE党注意了:此课程不支持IE9版本以下,建议使用 chromesafarifirefoxopera浏览器的最高版本学习本课程。

 

任务

右边的代码是CSS3实现的文字特效,你可以随意修改代码的几个参数看看有什么变化。

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Hello CSS3</title>
  6. <link href='http://fonts.googleapis.com/css?family=Fruktur' rel='stylesheet' type='text/css'>
  7. <link href="style.css" rel="stylesheet" type="text/css">
  8. </head>
  9. <body>
  10. <h1>Hello CSS3</h1>
  11. </body>
  12. </html>
  1. body{
  2. background:#000;
  3. }
  4.  
  5. h1 {
  6. text-align:center;
  7. color:#fff;
  8. font-size:48px;
  9. font-family: 'Fruktur', cursive;
  10. text-shadow: 1px 1px 1px #ccc,
  11. 0 0 10px #fff,
  12. 0 0 20px #fff,
  13. 0 0 30px #fff,
  14. 0 0 40px #ff00de,
  15. 0 0 70px #ff00de,
  16. 0 0 80px #ff00de,
  17. 0 0 100px #ff00de,
  18. 0 0 150px #ff00de;
  19.  
  20. transform-style: preserve-3d;
  21. -moz-transform-style: preserve-3d;
  22. -webkit-transform-style: preserve-3d;
  23. -ms-transform-style: preserve-3d;
  24. -o-transform-style: preserve-3d;
  25.  
  26.  
  27. animation: run ease-in-out 9s infinite;
  28. -moz-animation: run ease-in-out 9s infinite ;
  29. -webkit-animation: run ease-in-out 9s infinite;
  30. -ms-animation: run ease-in-out 9s infinite;
  31.  
  32. -o-animation: run ease-in-out 9s infinite;
  33. }
  34.  
  35. @keyframes run {
  36. 0% {
  37. transform:rotateX(-5deg) rotateY(0);
  38. }
  39. 50% {
  40. transform:rotateX(0) rotateY(180deg);
  41. text-shadow: 1px 1px 1px #ccc,
  42. 0 0 10px #fff,
  43. 0 0 20px #fff,
  44. 0 0 30px #fff,
  45. 0 0 40px #3EFF3E,
  46. 0 0 70px #3EFFff,
  47. 0 0 80px #3EFFff,
  48. 0 0 100px #3EFFee,
  49. 0 0 150px #3EFFee;
  50.  
  51. }
  52. 100% {
  53. transform:rotateX(5deg) rotateY(360deg);
  54. }
  55. }
  56.  
  57. @-moz-keyframes run {
  58. 0% {
  59. -moz-transform:rotateX(-5deg) rotateY(0);
  60.  
  61. }
  62. 50% {
  63. -moz-transform:rotateX(0) rotateY(180deg);
  64. text-shadow: 1px 1px 1px #ccc,
  65. 0 0 10px #fff,
  66. 0 0 20px #fff,
  67. 0 0 30px #fff,
  68. 0 0 40px #3EFF3E,
  69. 0 0 70px #3EFFff,
  70. 0 0 80px #3EFFff,
  71. 0 0 100px #3EFFee,
  72. 0 0 150px #3EFFee;
  73.  
  74. }
  75. 100% {
  76. -moz-transform:rotateX(5deg) rotateY(360deg);
  77. }
  78. }
  79.  
  80. @-webkit-keyframes run {
  81. 0% {
  82. -webkit-transform:rotateX(-5deg) rotateY(0);
  83.  
  84. }
  85. 50% {
  86. -webkit-transform:rotateX(0) rotateY(180deg);
  87. text-shadow: 1px 1px 1px #ccc,
  88. 0 0 10px #fff,
  89. 0 0 20px #fff,
  90. 0 0 30px #fff,
  91. 0 0 40px #3EFF3E,
  92. 0 0 70px #3EFFff,
  93. 0 0 80px #3EFFff,
  94. 0 0 100px #3EFFee,
  95. 0 0 150px #3EFFee;
  96.  
  97. }
  98. 100% {
  99. -webkit-transform:rotateX(5deg) rotateY(360deg);
  100. }
  101. }
  102. @-ms-keyframes run {
  103. 0% {
  104. -ms-transform:rotateX(-5deg) rotateY(0);
  105.  
  106. }
  107. 50% {
  108. -ms-transform:rotateX(0) rotateY(180deg);
  109.  
  110. }
  111. 100% {
  112. -ms-transform:rotateX(5deg) rotateY(360deg);
  113. }
  114. }
  115.  
  116.  
  117. </style>
下一节