CSS:line-height:行高

來源:互聯網
上載者:User

標籤:css   大小   覆蓋   預設   idt   orm   microsoft   ble   soft   

 

行高=文字尺寸+行距;

一般情況下,瀏覽器預設的line-height為1.2。可以自訂 line-height 覆蓋這個初始值,那麼該怎樣設定line-height呢?有以下5種方式:

值 描述
normal 預設。設定合理的行間距。
number 設定數字,此數字會與當前的字型尺寸相乘來設定行間距,即number為當前font-size的倍數。
length 設定固定的行間距。不會隨著文字大小變化
% 基於當前字型尺寸的百分比行間距。
inherit 規定應該從父元素繼承 line-height 屬性的值。

     一般來說設定為1.5e之類的最好,行高可以根據自己縮放而改變

設定方式   line-height   計算後的line-height 子項目繼承的line-heightinherit
inherit 父元素的line-height值 不用計算 父元素的line-height
length 20px 不用計算 20px

% 120% 自身font-size (16px) * 120% = 19.2px 繼承父元素計算後的line-height值 19.2px,而不是120%
normal 1.2
自身font-size (16px) * 1.2 = 19.2px
繼承1.2,line-height = 自身font-size(32px) * 1.2 = 38.4px
純數字 1.5 自身font-size (16px) * 1.2 = 19.2px 繼承1.5,line-height = 自身font-size(32px) * 1.5 = 48px

 

CSS:line-height:行高

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.