CSS3:text-shadow属性、word-wrap属性、transform属性、transition属性、animation属性、3D变换:transform-style:preserve-3d

浅浅的花香味﹌ 2024-03-24 16:08 92阅读 0赞

text-shadow属性:

text-shadow属性:水平偏移 垂直偏移 阴影大小 颜色

word-wrap属性:

word-wrap属性:允许长单词、URL强制进行换行。normal(默认)、break-word(长单词换行)。

@font-face规则:

  1. <style type="text/css">
  2. @font-face {
  3. font-family: name; /* 定义字体名称 */
  4. src: url(fonts/mc.ttf); /* 定义字体来源 */
  5. }
  6. p{
  7. font-family: name; /* 引用自定义字体名称 */
  8. }
  9. </style>

2D转换方法:对元素进行旋转、缩放、移动、拉伸 。

transform属性:rotate( )、scale( )

旋转:transform:rotate( deg); //单位deg. 当值为正时,顺时针旋转,为负值时逆时针旋转。

缩放:transform:scale(x,y); x:水平方向缩放的倍数. y:垂直方向缩放的倍数,若省略,同x.

0~1,缩小。大于1放大。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <style type="text/css">
  7. #t{
  8. border: 1px solid black;
  9. width: 300px;
  10. height: 300px;
  11. margin: 0 auto;
  12. }
  13. #right{
  14. margin: 15px auto;
  15. border: 1px solid black;
  16. width: 150px;
  17. height: 100px;
  18. text-align: center;
  19. line-height: 100px;
  20. transform: rotate(30deg); /* 顺时针旋转30度 */
  21. }
  22. #left{
  23. margin: 15px auto;
  24. border: 1px solid black;
  25. width: 150px;
  26. height: 100px;
  27. text-align: center;
  28. line-height: 100px;
  29. transform: rotate(-30deg); /* 逆时针旋转30度 */
  30. }
  31. #left:hover{
  32. transform: scale(1.5); /* 放大1.5倍 */
  33. }
  34. </style>
  35. </head>
  36. <body bgcolor="white">
  37. <div id="t">
  38. <div id="right">旋转与缩放</div>
  39. <div id="left">旋转与缩放</div>
  40. </div>
  41. </body>
  42. </html>

transition属性:

过渡:transition:将元素的 某个属性从“一个值”在指定的时间内过渡到“另一个值”。

transition: 属性名 持续时间 过渡方法;属性名多个时用“ ,”隔开,或用all表示所有属性。

过渡方法的取值有:




























描述
linear 匀速
ease 快慢快
ease-in 慢快
ease-out 快慢
ease-in-out 慢快慢

animation属性:动画

(1)定义动画——>@keyframes规则。

(2)调用动画——>animation属性。

animation属性


























描述
animation 简写
animation-name 引用@keyframes动画的名称
animation-duration 动画完成时间
animation-timing-function 规定动画的速度曲线。默认是“ease”
animation-play-state running | paused
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <style type="text/css">
  7. @keyframes wdcolor /* 动画名称 */
  8. {
  9. 0% {background-color:red; color: blue;}
  10. 30% {background-color:blue; color: red;}
  11. 60% {background-color:yellow; color: green;}
  12. 100% {background-color:green; color: yellow;}
  13. }
  14. #s:hover{
  15. animation: wdcolor 5s linear;
  16. }
  17. #s{
  18. margin-top: 50px;
  19. width: 300px;
  20. height: 200px;
  21. text-align: center;
  22. line-height: 200px;
  23. font-size: 25px;
  24. font-weight:bold;
  25. border: 1px solid white;
  26. background-color: black;
  27. color: white;
  28. }
  29. </style>
  30. </head>
  31. <body bgcolor="white">
  32. <div id="s">
  33. 动画效果
  34. </div>
  35. </body>
  36. </html>

3D变换:transform-style:preserve-3d

transform属性:

延X轴方向旋转:rotateX( deg)

延Y轴方向旋转:rotateY( deg):

延Z轴方向旋转:rotateZ( deg):

透视属性:perspective;

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <style type="text/css">
  7. #r{
  8. width: 1200px;
  9. border: 1px solid blue;
  10. height: 700px;
  11. margin: 10px auto;
  12. perspective: 800px;
  13. }
  14. img{
  15. width: 300px;
  16. height:500px;
  17. }
  18. #x,#y,#z{
  19. width: 302px;
  20. height: 502px;
  21. float: left;
  22. margin-left: 40px;
  23. margin-top: 100px;
  24. transition: linear 1s;
  25. transform-style: preserve-3d;
  26. border: 1px solid blue;
  27. }
  28. #x:hover{
  29. transform: rotateX(30deg);
  30. }
  31. #y:hover{
  32. transform: rotateY(180deg);
  33. }
  34. #z:hover{
  35. transform: rotateZ(60deg);
  36. }
  37. </style>
  38. </head>
  39. <body bgcolor="white">
  40. <div id="r">
  41. <div id="x">
  42. <img src="picture/45.png" />
  43. </div>
  44. <div id="y">
  45. <img src="picture/45.png "/>
  46. </div>
  47. <div id="z">
  48. <img src="picture/45.png "/>
  49. </div>
  50. </div>
  51. </body>
  52. </html>

发表评论

表情:
评论列表 (有 0 条评论,92人围观)

还没有评论,来说两句吧...

相关阅读