Alexus
Alexus

Reputation: 952

Why is chrome rendering this CSS in such a way

I was trying to create a circle with i icon in it for with CSS. However, when page is first rendered the circle looks like an inverted egg and covers the border around it slightly. (Zoom in the browser to see issue in more details)

The tricky part is, if you open Dev Tools and change any value related to it's position(width, height, whatever), everything will snap back to normal and it will become a circle.

https://jsfiddle.net/2yjashje/

<div class="round-egg">
    i
</div>


.round-egg {
    font-size: 14px;
    background: white;
    color: #8DC641;
    border-radius: 10px;
    cursor: help;
    border-bottom: none !important;
    border: 4px solid #8DC641;
    width: 20px;
    height: 20px;
    text-align: center;
}

What is going on here?

Upvotes: 0

Views: 57

Answers (1)

9997
9997

Reputation: 1357

I put the letter "i" in its own span and increased the margin from top to vertically centre it. As for the circle, I modified the border-radius property, and then removed the border-bottom: none; property as well. Assuming you want a circle, you need the bottom border.

https://jsfiddle.net/2yjashje/3/

<div class="round-egg">
    <span class="icon">i</span>
</div>

.round-egg {
    font-size: 14px;
    background: white;
    color: #8DC641;
    border-radius: 30px;
    cursor: help;
    border: 4px solid #8DC641;
    width: 20px;
    height: 20px;
    text-align: center;
    display: table-cell;
}
.icon {
   display: block;
   margin-top: 2px;
}

Upvotes: 1

Related Questions