How does this CSS produce a circle?

前端 未结 5 2148
鱼传尺愫
鱼传尺愫 2020-11-28 00:30

This is the CSS:

div {
    width: 0;
    height: 0;
    border: 180px solid red;
    border-radius: 180px;
}

How does it produce the circle

5条回答
  •  孤城傲影
    2020-11-28 00:52

    Both .a and .b will give the identical output.

    Q. Why did I used width: 360px; height: 360px;?

    A. border: 180px solid red; in .a works like border-width: 180px 180px 180px 180px; /* Top Right Bottom Left */.

    Hope this fiddle helps you to understand the concept.

    .a{
        width: 0;
        height: 0;
        border: 180px solid red;
        border-radius: 180px;
    }
    .b{
        background:red;
        width: 360px;
        height: 360px;
        border-radius: 180px;
    }
    

提交回复
热议问题