css中height和line-height區別

來源:互聯網
上載者:User
這篇文章主要介紹了css中height和line-height區別,需要的朋友可以參考下line-height:行高 設定文字間上下距離
height:高度 就是定義一個層 或某樣東西的高度啦

也就是說line-height是特指單行高度,height可以為所有元素的高度

文字放大後邊緣會重疊?

line-height直白理解就是文字高度加上文字上下的空白地區,line-height最好不要設定單位,如果固定單位後,行高就是確定值。

當字型放大且沒有設定元素的line-height(繼承自父元素且父元素為固定值)或者其值為固定值就會出現文字超出行高範圍出現重疊。

line-height有繼承屬性,所以本文部分內容line-height最好設定為為數字1.5,也就是字型高度*1.5的高度,

這樣行高會隨著字型縮放跟著縮放。

如何設定文字圖片行內置中?

line-height預設是baseline對其的,可以使用vertical-align:middle使其文字圖片置中對齊。

如何更加易讀?

行內文字背景顏色#fff,文字顏色#333;文字周圍有空白line-height行高1.25-1.5,減少壓迫感,本文大小為14px,其它可以為12px。

input button 各個瀏覽器表現一致。

firefox預設的linde-height值預設為normal,需要明確指定。

代碼如下:

button, input[type="button"], input[type="submit"] {
line-height:normal !important;
}
input.button, a.button, button {
font: bold 12px Arial, Helvetica, sans-serif;
padding: 5px 8px;
overflow:visible;
}

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.