Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border radius circle

Tags:

I've this code :

span p {
    margin: 0;
}

span {
    background-color: red;
    display: inline-block;
    border-radius: 50%;
}
<span>
    <p>25</p>
    <p>08</p>
</span>

I want to make a perfect circle on my span. I try a border-radius: 50%; but it does not work.

Thanks for the help !

like image 393
Corentin Branquet Avatar asked Aug 25 '15 08:08

Corentin Branquet


People also ask

What is border radius?

The border-radius property defines the radius of the element's corners. Tip: This property allows you to add rounded corners to elements! This property can have from one to four values.

Why border radius is not working?

Your problem is unrelated to how you have set border-radius . Fire up Chrome and hit Ctrl+Shift+j and inspect the element. Uncheck width and the border will have curved corners. Show activity on this post.


2 Answers

You need a predefined width and height on the span to be able to make it round.

span p {
    margin: 0;
}

span {
    background-color: red;
    display: inline-block;
    border-radius: 50%;
    width:40px;
    height:40px;
    padding-left:10px;
    box-sizing: border-box;
}
<span>
    <p>25</p>
    <p>08</p>
</span>
like image 31
Eric Mitjans Avatar answered Oct 20 '22 17:10

Eric Mitjans


You can do this by giving the span a fixed width and height:

span p {
    margin: 0;
}

span {
    background-color: red;
    display: inline-block;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    text-align: center;
}
<span>
    <p>25</p>
    <p>08</p>
</span>
like image 135
GolezTrol Avatar answered Oct 20 '22 17:10

GolezTrol