CSS

1、弹动效果实现

代码实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>
  8. CSS个人博客样式特效实例
  9. </title>
  10. <style>
  11. .shake{
  12. width:40px;
  13. height:40px;
  14. display:block;
  15. background:lightgreen;
  16. border-radius:50%;
  17. margin:5px;
  18. color:#fff;
  19. font-size:24px;
  20. text-align:center;
  21. line-height:40px;
  22. cursor:pointer;
  23. -webkit-transition:all 0.25s;
  24. }
  25. .shake:hover{
  26. -webkit-animation:shake 0.25s;
  27. background: lightblue;
  28. }
  29. @-webkit-keyframes shake{
  30. 0%,10%,55%,90%,94%,98%,100%{
  31. -webkit-transform:scale(1,1);
  32. }
  33. 30%{
  34. -webkit-transform:scale(1.14,0.86);
  35. }
  36. 75%{
  37. -webkit-transform:scale(0.92,1.08);
  38. }
  39. 92%{
  40. -webkit-transform:scale(1.04,0.96);
  41. }
  42. 96%{
  43. -webkit-transform:scale(1.02,0.98);
  44. }
  45. 99%{
  46. -webkit-transform:scale(1.01,0.99);
  47. }
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <span class="shake"></span>
  53. </body>
  54. </html>

效果

GIF 2020-9-11-星期五 21-38-39.gif

2、搜索框输入时拉伸

代码实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>
  8. CSS个人博客样式特效实例
  9. </title>
  10. <style>
  11. .search{
  12. width:80px;
  13. height:40px;
  14. border-radius:40px;
  15. border:2px solid lightblue;
  16. position: absolute;
  17. right:200px;
  18. outline:none;
  19. text-indent:12px;
  20. color:#666;
  21. font-size:16px;
  22. padding:0;
  23. -webkit-transition:width 0.5s;
  24. }
  25. .search:focus{
  26. width:200px;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <input class="search" type="text" placeholder="搜索...">
  32. </body>
  33. </html>

效果

GIF 2020-9-11-星期五 21-41-29.gif

3、旋转条样式

代码实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>
  8. CSS个人博客样式特效实例
  9. </title>
  10. <style>
  11. .banner{
  12. width:234px;
  13. height:34px;
  14. border-radius:34px;
  15. position:absolute;
  16. top:400px;
  17. left:200px;
  18. }
  19. .banner a{
  20. display:inline-block;
  21. width:30px;
  22. height:30px;
  23. line-height:30px;
  24. border-radius:50%;
  25. border:2px solid lightblue;
  26. position:absolute;
  27. left:0px;top:0px;
  28. background:lightgreen;
  29. color:#fff;
  30. text-align:center;
  31. text-decoration:none;
  32. cursor:pointer;
  33. z-index:2;
  34. }
  35. .banner a:hover + span{
  36. -webkit-transform:rotate(360deg);
  37. opacity:1;
  38. }
  39. .banner span{
  40. display:inline-block;
  41. width:auto;
  42. padding:0 20px;
  43. height:34px;
  44. line-height:34px;
  45. background:lightblue;
  46. border-radius:34px;
  47. text-align: center;
  48. position:absolute;
  49. color:#fff;
  50. text-indent:25px;
  51. opacity:0;
  52. -webkit-transform-origin:8% center;
  53. -webkit-transition:all 1s;
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <div class="banner">
  59. <a href="javascript:;"></a>
  60. <span>这是我的个人博客</span>
  61. </div>
  62. </body>
  63. </html>

效果

GIF 2020-9-11-星期五 21-46-07.gif

4、右进右出条样式

代码实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>
  8. CSS个人博客样式特效实例
  9. </title>
  10. <style>
  11. .banner{
  12. width:234px;
  13. height:34px;
  14. border-radius:40px;
  15. position:absolute;
  16. top:400px;
  17. left:600px;
  18. }
  19. .banner a{
  20. display:inline-block;
  21. width:30px;
  22. height:30px;
  23. line-height:30px;
  24. border-radius:50%;
  25. border:2px solid lightblue;
  26. position:absolute;
  27. left:0px;top:0px;
  28. background:lightgreen;
  29. color:#fff;
  30. text-align:center;
  31. text-decoration:none;
  32. cursor:pointer;
  33. z-index:2;
  34. }
  35. .banner a:hover + span{
  36. -webkit-transform:translateX(40px);
  37. opacity:1;
  38. }
  39. .banner span{
  40. display:inline-block;
  41. width:auto;
  42. padding:0 20px;
  43. height:30px;line-height:30px;
  44. background:lightblue;
  45. border-radius:30px;
  46. text-align: center;
  47. color:#fff;
  48. position:absolute;
  49. top:2px;
  50. opacity:0;
  51. -webkit-transition:all 1s;
  52. -webkit-transform:translateX(80px);
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="banner">
  58. <a href="javascript:;"></a>
  59. <span>这是我的个人博客</span>
  60. </div>
  61. </body>
  62. </html>

效果

GIF 2020-9-11-星期五 21-50-36.gif

5、旋转标签

代码实现

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content=
  6. "width=device-width, initial-scale=1.0" />
  7. <title>
  8. CSS个人博客样式特效实例
  9. </title>
  10. <style>
  11. .wrapper{
  12. width:100px;
  13. height:100px;
  14. background:lightblue;
  15. border-radius:50%;
  16. border:2px solid lightgreen;
  17. position: absolute;
  18. top:200px;
  19. left:400px;
  20. cursor:pointer;
  21. }
  22. .wrapper:after{
  23. content:'你猜';
  24. display:inline-block;
  25. width:100px;
  26. height:100px;
  27. line-height:100px;
  28. border-radius:50%;
  29. text-align:center;
  30. color:#fff;
  31. font-size:24px;
  32. }
  33. .wrapper:hover .round{
  34. -webkit-transform:scale(1);
  35. opacity:1;
  36. -webkit-animation:rotating 6s 1.2s linear infinite alternate;
  37. }
  38. @-webkit-keyframes rotating{
  39. 0%{
  40. -webkit-transform:rotate(0deg);
  41. }
  42. 100%{
  43. -webkit-transform:rotate(180deg);
  44. }
  45. }
  46. .round{
  47. width:240px;
  48. height:240px;
  49. border:2px solid lightgreen;
  50. border-radius:50%;
  51. position: absolute;
  52. top:-70px;
  53. left:-70px;
  54. -webkit-transition:all 1s;
  55. -webkit-transform:scale(0.35);
  56. opacity:0;
  57. }
  58. .round span{
  59. width:40px;
  60. height:40px;
  61. line-height:40px;
  62. display:inline-block;
  63. border-radius:50%;
  64. background:lightblue;
  65. border:2px solid lightgreen;
  66. color:#fff;
  67. text-align:center;
  68. position:absolute;
  69. }
  70. .round span:nth-child(1){
  71. right:-22px;
  72. top:50%;
  73. margin-top:-22px;
  74. }
  75. .round span:nth-child(2){
  76. left:-22px;
  77. top:50%;
  78. margin-top:-22px;
  79. }
  80. .round span:nth-child(3){
  81. left:50%;
  82. bottom:-22px;
  83. margin-left:-22px;
  84. }
  85. .round span:nth-child(4){
  86. left:50%;
  87. top:-22px;
  88. margin-left:-22px;
  89. }
  90. </style>
  91. </head>
  92. <body>
  93. <div class="wrapper">
  94. <div class="round">
  95. <span>东邪</span>
  96. <span>西毒</span>
  97. <span>南乞</span>
  98. <span>北丐</span>
  99. </div>
  100. </div>
  101. </body>
  102. </html>

效果

GIF 2020-9-11-星期五 21-53-50.gif