当前位置:   article > 正文

css制作梯形_css 梯形

css 梯形

用css制作梯形最常用的方法就是通clip-path来裁剪一个长方形。通过设置polygon属性4个顶点的位置达到效果。

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>css制作梯形</title>
  8. <style>
  9. .tx {
  10. width: 400px;
  11. height: 240px;
  12. border: 1px solid rebeccapurple;
  13. text-align: center;
  14. line-height: 240px;
  15. background-color: aquamarine;
  16. clip-path: polygon(30% 0%, 70% 0%, 100% 100%, 0% 100%);
  17. }
  18. .tx1 {
  19. width: 400px;
  20. height: 240px;
  21. border: 1px solid rebeccapurple;
  22. text-align: center;
  23. line-height: 240px;
  24. background-color: aquamarine;
  25. clip-path: polygon(30% 0%, 100% 0%, 100% 100%, 0% 100%);
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <h1 class="tx">等腰梯形</h1>
  31. <h1 class="tx1">直角梯形</h1>
  32. </body>
  33. </html>

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/150769
推荐阅读
相关标签