CSS – 同心圆

前端之家收集整理的这篇文章主要介绍了CSS – 同心圆前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

参见英文答案 > Concentric circles with CSS                                    6个
我想在CSS中创建两个同心圆.内部的一个具有与外部宽度相当的指定宽度,例如. 50%.这些圈子应该是响应性的,它们应该适合所有屏幕.

我怎样才能做到这一点?我不喜欢使用position:absolute,javascript或jQuery.我认为这应该是可能的.

谢谢!

最佳答案
纯CSS:

  1. #container {
  2. position: relative;
  3. width: 100%;
  4. padding-bottom: 100%;
  5. }
  6. #circle {
  7. position: absolute;
  8. width: 50%;
  9. height: 50%;
  10. background-color: #000000;
  11. border-radius: 50%;
  12. }
  13. #small-circle{
  14. margin-top: 25%;
  15. margin-left: 25%;
  16. position: absolute;
  17. width: 50%;
  18. height: 50%;
  19. background-color: #e5e5e5;
  20. border-radius: 50%;
  21. }

和HTML:

Demo

猜你在找的CSS相关文章