原理

一张图说明问题:
image.png
其实就是我们认为指定圆的半径,圆和矩形相切的时候就是最终的效果了。

语法

border-radius:length;
  • 参数可以为数值或百分比的形式

数值:多少像素
百分比:半径为宽高的原宽高比例的多少
image.png

演示

  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>圆角矩形</title>
  8. <style>
  9. div{
  10. background-color: plum;
  11. }
  12. .radio{
  13. width: 200px;
  14. height: 200px;
  15. border-radius: 100px;
  16. }
  17. .radioJiao{
  18. width: 200px;
  19. height: 100px;
  20. margin: 20px;
  21. margin-left: 0px;
  22. border-radius: 50px;
  23. }
  24. .bord{
  25. width: 200px;
  26. height: 200px;
  27. border-radius: 30px 10px;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <div class="radio"></div>
  33. <div class="radioJiao"></div>
  34. <div class="bord"></div>
  35. </body>
  36. </html>

image.png