我無法使按鈕高度與不同的字體大小相同。我必須使用em來設置響應式設計的高度和寬度。如何使按鈕高度與不同的字體大小相同
這裏是例子jsfiddle
CSS:
body{
font-size:16px;
}
.btn{
height:4em;
font-size:1em;
}
.btn2{
height:4em;
font-size:1.50em;
}
HTML:
<button class="btn">First Button is 64px as expected</button>
<br><br>
<button class="btn2">Why this is not same height with first one?</button>
<p>
How to make same height buttons with differnet font sizes ?
</p>
試圖給他們兩個相同的寬度 –
是的。當你給相同的寬度,它按預期工作。但爲什麼 ?這是一個錯誤?這裏更新並且正在工作。兩者都具有相同的寬度和預期工作。 https://jsfiddle.net/ynxqjytz/4/ –
那是因爲你正在使用EM取決於字體大小。 –