15

i want to create a div with background color red and completely circular in shape

How can i do that?

Css or jquery both can be used

jbutler483
  • 24,074
  • 9
  • 92
  • 145
Saswat
  • 12,320
  • 16
  • 77
  • 156

6 Answers6

28

You can do following

FIDDLE

<div id="circle"></div>

CSS

#circle {
    width: 100px;
    height: 100px;
    background: red;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
}

Other shape SOURCE

Richa
  • 3,261
  • 2
  • 27
  • 51
6

By using a border-radius of 50% you can make a circle. Here is an example:

CSS:

#exampleCircle{
    width: 500px;
    height: 500px;
    background: red;
    border-radius: 50%;
}

HTML:

<div id = "exampleCircle"></div>
Nirvik Baruah
  • 1,643
  • 2
  • 19
  • 20
4

Demo

css

div {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: red;
}

html

<div></div>
4dgaurav
  • 11,360
  • 4
  • 32
  • 59
4

HTML div elements, unlike SVG circle primitives, are always rectangular.

You could use round corners (i.e. CSS border-radius) to make it look round. On square elements, a value of 50% naturally forms a circle. Use this, or even a SVG inside your HTML:

document.body.innerHTML+='<i></i>'.repeat(4);
i{border-radius:50%;display:inline-block;background:#F48024;}
svg {fill:#F48024;width:60px;height:60px;}
i:nth-of-type(1n){width:30px;height:30px;}
i:nth-of-type(2n){width:60px;height:60px;}
<svg viewBox="0 0 120 120" xmlns="http://www.w3.org/2000/svg">
  <circle cx="60" cy="60" r="60"/>
</svg>
dakab
  • 5,379
  • 9
  • 43
  • 67
3

Use a border-radius property of 50%.

So for example:

.example-div {

    border-radius: 50%

}
Kevin Damstra
  • 125
  • 2
  • 13
1
.circle {
    border-radius: 50%;
    width: 500px;
    height: 500px;
    background: red;
}

<div class="circle"></div>

see this FIDDLE

bumbumpaw
  • 2,522
  • 1
  • 24
  • 54