-2
圓圈中的數字有許多解決方案,但它們使用固定大小。如何設置圓形div的樣式以包含居中的文字或最大可能的字體數以適合圓形?如何用中間的數字創建一個圓圈,以適應HTML/CSS中的圓圈?
圓圈中的數字有許多解決方案,但它們使用固定大小。如何設置圓形div的樣式以包含居中的文字或最大可能的字體數以適合圓形?如何用中間的數字創建一個圓圈,以適應HTML/CSS中的圓圈?
我認爲這段代碼可以解決你的問題。只要確保父字體的字體大小和寬度相同(在本例中爲5 rem)。
div{
font-size: 5rem;
width: 5rem;
background-color: aquamarine;
padding: 1rem;
display: inline-flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
<div>5</div>
我看到...生病嘗試來縮小問題 –
複製 - http://stackoverflow.com/questions/41855730/css-circle-without-fixed-width-and -height/41856203#41856203 –
[CSS - 沒有固定寬度和高度的圓形]的可能重複(http://stackoverflow.com/questions/41855730/css-circle-without-fixed-width-and-height) – bancer