博主信息
博文 7
粉丝 1
评论 0
访问量 6548
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
CSS基础知识:实现了太极图文详解
Lucas
原创
621人浏览过

一、CSS实现太极图的写法

1、第一种静态:CSS实现太极图的写法

html 页面

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .dayuan{
  8. position: absolute;
  9. align-items: center;
  10. width: 400px;
  11. height: 400px;
  12. border: 1px solid darkgray;
  13. border-radius: 50%;
  14. }
  15. .heise{
  16. width: 400px;
  17. height: 200px;
  18. background: #000000;
  19. border-radius: 200px 200px 0 0;
  20. }
  21. .yuan-l{
  22. position: relative;
  23. top: -100px;
  24. display: flex;
  25. align-items: center;
  26. justify-content: center;
  27. float: left;
  28. width: 200px;
  29. height: 200px;
  30. background: #000000;
  31. border-radius: 50%;
  32. position: relative;
  33. }
  34. .yuan-r{
  35. position: relative;
  36. top: -100px;
  37. display: flex;
  38. align-items: center;
  39. justify-content: center;
  40. float: right;
  41. width: 200px;
  42. height: 200px;
  43. background: #ffffff;
  44. border-radius: 50%;
  45. }
  46. .xy-l{
  47. width: 50px;
  48. height: 50px;
  49. background: #fff;
  50. border-radius: 50%;
  51. }
  52. .xy-r{
  53. width: 50px;
  54. height: 50px;
  55. background: #000000;
  56. border-radius: 50%;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <div class="dayuan">
  62. <div class="heise"></div>
  63. <div class="yuan-l">
  64. <div class="xy-l"></div>
  65. </div>
  66. <div class="yuan-r">
  67. <div class="xy-r"></div>
  68. </div>
  69. </div>
  70. </body>
  71. </html>

页面效果图

2、第二种动画方法:CSS实现旋转太极图

index.html 页面

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. .dayuan{
  8. position: absolute;
  9. align-items: center;
  10. width: 400px;
  11. height: 400px;
  12. border: 1px solid darkgray;
  13. border-radius: 50%;
  14. animation: dayuan 8s linear infinite;/* 加上动画属性 8s是速度8秒 linear是均速 infinite是循环无限的 */
  15. }
  16. .heise{
  17. width: 400px;
  18. height: 200px;
  19. background: #000000;
  20. border-radius: 200px 200px 0 0;
  21. }
  22. .yuan-l{
  23. position: relative;
  24. top: -100px;
  25. display: flex;
  26. align-items: center;
  27. justify-content: center;
  28. float: left;
  29. width: 200px;
  30. height: 200px;
  31. background: #000000;
  32. border-radius: 50%;
  33. position: relative;
  34. }
  35. .yuan-r{
  36. position: relative;
  37. top: -100px;
  38. display: flex;
  39. align-items: center;
  40. justify-content: center;
  41. float: right;
  42. width: 200px;
  43. height: 200px;
  44. background: #ffffff;
  45. border-radius: 50%;
  46. }
  47. .xy-l{
  48. width: 50px;
  49. height: 50px;
  50. background: #fff;
  51. border-radius: 50%;
  52. }
  53. .xy-r{
  54. width: 50px;
  55. height: 50px;
  56. background: #000000;
  57. border-radius: 50%;
  58. }
  59. /* 加上动画属性:在CSS3中,可以利用transform功能来实现太极图像的旋转,rotate是旋转,deg为度的意思,正数为顺时针旋转,负数为逆时针旋转 */
  60. @keyframes dayuan{
  61. 0%{
  62. transform: rotate(0deg);
  63. }
  64. 100%{
  65. transform: rotate(-360deg);
  66. }
  67. }
  68. </style>
  69. </head>
  70. <body>
  71. <div class="dayuan">
  72. <div class="heise"></div>
  73. <div class="yuan-l">
  74. <div class="xy-l"></div>
  75. </div>
  76. <div class="yuan-r">
  77. <div class="xy-r"></div>
  78. </div>
  79. </div>
  80. </body>
  81. </html>

效果图如下

小总结

学习到了css的盒子模型和动画属性,这有好玩的动画,比如css中可以利用transform功能来实现图像的旋转、缩放、倾斜、移动等类型的变形处理。继续学习中,加油~

批改老师:PHPzPHPz

批改状态:合格

老师批语:漂亮
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

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

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学