当前位置:   article > 正文

css 常见图形绘制_css shape-sub

css shape-sub

 1.心形

  1. // 心形
  2. <div class="shape-sub"></div>
  3. .shape-sub:before,.shape-sub:after{
  4. content: "";
  5. position: absolute;
  6. left:50px;
  7. top:0;
  8. width:50px;
  9. height:80px;
  10. background:red;
  11. border-radius: 50px 50px 0;
  12. transform:rotate(-45deg);
  13. transform-origin: 0 100%;
  14. }
  15. .shape-sub:after{
  16. left:0;
  17. transform: rotate(45deg);
  18. transform-origin:100% 100%;
  19. }

2.三角形

                                      

  1. // 三角形
  2. <div class="triangle-up">向上</div>
  3. <div class="triangle-down">向下</div>
  4. <div class="triangle-left">向左</div>
  5. <div class="triangle-right">向右</div>
  6. .triangle-up{
  7. width: 0;
  8. height: 0;
  9. border-left: 30px solid transparent;
  10. border-right: 30px solid transparent;
  11. border-bottom: 30px solid red;
  12. }
  13. .triangle-down {
  14. width: 0;
  15. height: 0;
  16. border-left: 30px solid transparent;
  17. border-right: 30px solid transparent;
  18. border-top: 30px solid red;
  19. }
  20. .triangle-left {
  21. width: 0;
  22. height: 0;
  23. border-top: 30px solid transparent;
  24. border-bottom: 30px solid transparent;
  25. border-right: 30px solid red;
  26. }
  27. .triangle-right {
  28. width: 0;
  29. height: 0;
  30. border-top: 30px solid transparent;
  31. border-left: 30px solid red;
  32. border-bottom: 30px solid transparent;
  33. }

3.菱形

            

  1. // 菱形
  2. <div class="shape-sub1"></div>
  3. <div class="shape-sub2"></div>
  4. .shape-sub1 {
  5. width: 100px;
  6. height: 60px;
  7. margin: 50px 0 0 50px;
  8. transform: skew(30deg);
  9. background: red;
  10. }
  11. .shape-sub2 {
  12. width: 100px;
  13. height: 60px;
  14. margin: 50px 0 0 50px;
  15. transform: skew(-30deg);
  16. background: red;
  17. }

4.五角星

 

  1. // 五角星
  2. <div class="shape-sub5"></div>
  3. .shape-sub5 {
  4. display: block;
  5. position: relative;
  6. margin: 60px 0;
  7. color:red;
  8. width: 0;
  9. height: 0;
  10. border-right: 100px solid transparent;
  11. border-bottom: 70px solid red;
  12. border-left: 100px solid transparent;
  13. transform: rotate(35deg);
  14. }
  15. .shape-sub5:before{
  16. position: absolute;
  17. top:-45px;
  18. left:-65px;
  19. border-left: 30px solid transparent;
  20. border-right: 30px solid transparent;
  21. border-bottom: 80px solid red;
  22. height:0;
  23. width:0;
  24. display: block;
  25. content:"";
  26. transform: rotate(-35deg);
  27. }
  28. .shape-sub5:after{
  29. content:'';
  30. display: block;
  31. position: absolute;
  32. top: 3px;
  33. left: -105px;
  34. color: red;
  35. width:0;
  36. height:0;
  37. border-right: 100px solid transparent;
  38. border-bottom:70px solid red;
  39. border-left: 100px solid transparent;
  40. transform:rotate(-70deg);
  41. }

5.梯形

 

  1. // 梯形
  2. <div class="shape-sub3"></div>
  3. .shape-sub3 {
  4. width: 60px;
  5. height: 0;
  6. margin: 50px 0 0 50px;
  7. border-left: 30px solid transparent;
  8. border-right: 30px solid transparent;
  9. border-bottom: 60px solid red;
  10. }

6.椭圆形

  1. // 椭圆形
  2. <div class="ellipse"></div>
  3. .ellipse {
  4. width: 200px;
  5. height: 100px;
  6. background: red;
  7. border-radius: 100px / 50px;
  8. }

7.无限形

  1. // 无限形
  2. <div class="infinity"></div>
  3. .infinity {
  4. position: relative;
  5. width: 212px;
  6. height: 100px;
  7. box-sizing: content-box;
  8. }
  9. .infinity:before,
  10. .infinity:after {
  11. content: "";
  12. box-sizing: content-box;
  13. position: absolute;
  14. top: 0;
  15. left: 0;
  16. width: 60px;
  17. height: 60px;
  18. border: 20px solid red;
  19. border-radius: 50px 50px 0 50px;
  20. transform: rotate(-45deg);
  21. }
  22. .infinity:after {
  23. left: auto;
  24. right: 0;
  25. border-radius: 50px 50px 50px 0;
  26. transform: rotate(45deg);
  27. }

8.钻石形

  1. // 钻石形
  2. <div class="cut-diamond"></div>
  3. .cut-diamond {
  4. border-style: solid;
  5. border-color: transparent transparent red transparent;
  6. border-width: 0 25px 25px 25px;
  7. height: 0;
  8. width: 50px;
  9. box-sizing: content-box;
  10. position: relative;
  11. margin: 20px 0 50px 0;
  12. }
  13. .cut-diamond:after {
  14. content: "";
  15. position: absolute;
  16. top: 25px;
  17. left: -25px;
  18. width: 0;
  19. height: 0;
  20. border-style: solid;
  21. border-color: red transparent transparent transparent;
  22. border-width: 70px 50px 0 50px;
  23. }

9.蛋形

  1. // 蛋形
  2. <div class="egg"></div>
  3. .egg {
  4. display: block;
  5. width: 126px;
  6. height: 180px;
  7. background-color: red;
  8. border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  9. }

10.吃人豆

  1. // 吃人豆
  2. <div class="pacman"></div>
  3. .pacman {
  4. width: 0px; height: 0px;
  5. border-right: 60px solid transparent;
  6. border-top: 60px solid red;
  7. border-left: 60px solid red;
  8. border-bottom: 60px solid red;
  9. border-top-left-radius: 60px;
  10. border-top-right-radius: 60px;
  11. border-bottom-left-radius: 60px;
  12. border-bottom-right-radius: 60px;
  13. }

11.气泡

  1. // 气泡
  2. <div class="talkbubble"></div>
  3. .talkbubble {
  4. width: 120px; height: 80px;
  5. background: red;
  6. position: relative;
  7. border-radius: 10px;
  8. }
  9. .talkbubble:before {
  10. content: "";
  11. position: absolute;
  12. right: 100%; top: 26px;
  13. border-top: 13px solid transparent;
  14. border-right: 26px solid red;
  15. border-bottom: 13px solid transparent;
  16. }

12.八卦

  1. // 八卦
  2. <div class="ba-gua"></div>
  3. .ba-gua {
  4. width: 96px; height: 48px;
  5. background: #eee;
  6. border-color: red;
  7. border-style: solid;
  8. border-width: 2px 2px 50px 2px;
  9. border-radius: 100%;
  10. position: relative;
  11. }
  12. .ba-gua:before {
  13. content: "";
  14. position: absolute;
  15. top: 50%; left: 0;
  16. background: #fff;
  17. border: 18px solid red;
  18. border-radius: 100%;
  19. width: 12px; height: 12px;
  20. }
  21. .ba-gua:after {
  22. content: "";
  23. position: absolute;
  24. top: 50%;
  25. left: 50%;
  26. background: red;
  27. border: 18px solid #eee;
  28. border-radius: 100%;
  29. width: 12px;
  30. height: 12px;
  31. }

13.放大镜

  1. // 放大镜
  2. <div class="magnifying-glass"></div>
  3. .magnifying-glass {
  4. font-size: 10em;
  5. display: inline-block;
  6. width: 0.4em; height: 0.4em;
  7. border: 0.1em solid red;
  8. position: relative;
  9. border-radius: 0.35em;
  10. }
  11. .magnifying-glass:before {
  12. content: "";
  13. display: inline-block;
  14. position: absolute;
  15. right: -0.25em; bottom: -0.1em;
  16. border-width: 0;
  17. background: red;
  18. width: 0.35em; height: 0.08em;
  19. transform: rotate(45deg);
  20. }

14.月亮

  1. // 月亮
  2. <div class="moon"></div>
  3. .moon {
  4. width: 80px; height: 80px;
  5. border-radius: 50%;
  6. box-shadow: 15px 15px 0 0 red;
  7. }

15.圆锥形

  1. // 圆锥形
  2. <div class="cone"></div>
  3. .cone {
  4. width: 0; height: 0;
  5. border-left: 70px solid transparent;
  6. border-right: 70px solid transparent;
  7. border-top: 100px solid red;
  8. border-radius: 50%;
  9. }

16.指向图形

  1. // 指向图形
  2. <div class="pointer "></div>
  3. .pointer {
  4. width: 100px; height: 40px;
  5. position: relative;
  6. background: red;
  7. }
  8. .pointer:after {
  9. content: "";
  10. position: absolute;
  11. left: 0; bottom: 0;
  12. border-left: 20px solid white;
  13. border-top: 20px solid transparent;
  14. border-bottom: 20px solid transparent;
  15. }
  16. .pointer:before {
  17. content: "";
  18. position: absolute;
  19. right: -20px; bottom: 0;
  20. border-left: 20px solid red;
  21. border-top: 20px solid transparent;
  22. border-bottom: 20px solid transparent;
  23. }

17.加号

  1. // 加号
  2. <div class="cross"></div>
  3. .cross {
  4. background: red;
  5. width: 20px; height: 100px;
  6. position: relative;
  7. }
  8. .cross:after {
  9. background: red;
  10. content: "";
  11. width: 100px; height: 20px;
  12. position: absolute;
  13. left: -40px; top: 40px;
  14. }

18.指向箭头

  1. // 指向箭头
  2. <div class="curvedarrow"></div>
  3. .curvedarrow {
  4. position: relative;
  5. width: 0;
  6. border-top: 45px solid transparent;
  7. border-right: 45px solid red;
  8. transform: rotate(5deg) translateX(100%);
  9. }
  10. .curvedarrow:after {
  11. content: "";
  12. position: absolute;
  13. border: 0 solid transparent;
  14. border-top: 20px solid red;
  15. border-radius: 100px 0 0 0;
  16. top: -60px; left: -45px;
  17. width: 60px; height: 60px;
  18. transform: rotate(45deg);
  19. }

19.旗帜

  1. // 旗帜
  2. <div class="flag"></div>
  3. .flag {
  4. width: 80px;
  5. height: 56px;
  6. padding-top: 22px;
  7. position: relative;
  8. background: red;
  9. }
  10. .flag:after {
  11. content: "";
  12. position: absolute;
  13. left: 0;
  14. bottom: 0;
  15. border-bottom: 35px solid #fff;
  16. border-left: 40px solid transparent;
  17. border-right: 42px solid transparent;
  18. }

20.锁

  1. // 锁
  2. <div class="lock"></div>
  3. .lock {
  4. font-size: 8px;
  5. position: relative;
  6. width: 18em; height: 13em;
  7. border-radius: 2em;
  8. top: 10em;
  9. box-sizing: border-box;
  10. border: 3.5em solid red;
  11. border-right-width: 7.5em;
  12. border-left-width: 7.5em;
  13. margin: 0 0 6rem 0;
  14. }
  15. .lock:before {
  16. content: "";
  17. box-sizing: border-box;
  18. position: absolute;
  19. border: 2.5em solid red;
  20. width: 14em; height: 12em;
  21. left: 50%;
  22. margin-left: -7em; top: -12em;
  23. border-top-left-radius: 7em;
  24. border-top-right-radius: 7em;
  25. }
  26. .lock:after {
  27. content: "";
  28. box-sizing: border-box;
  29. position: absolute;
  30. border: 1em solid red;
  31. width: 5em; height: 8em;
  32. border-radius: 2.5em;
  33. left: 50%; top: -1em;
  34. margin-left: -2.5em;
  35. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/97021
推荐阅读
相关标签
  

闽ICP备14008679号