Maison > interface Web > tutoriel HTML > le corps du texte

<font>周边知识点_html/css_WEB-ITnose

WBOY
Libérer: 2016-06-24 11:50:22
original
1217 Les gens l'ont consulté

em

  1em = 元素自身设定的或是父元素继承的font-size值

1 <h1>left margin = <small>24px</small></h1>2 <h2>left margin = <small>18px</small></h2>3 <p>left margin = <small>12px</small></p>
Copier après la connexion

1 h1{font-size:24px;}2 h2{font-size:18px;}3 p{font-size:12px;}4 h1,h2,p{margin-left:1em;}
Copier après la connexion

font-weight

  值100~900并没有固定的加粗度,一般与某个变形名等价,400对应normal,700对应bold,其他视关键字情况而定。

Times假想加粗指定

字体 指定关键字 指定数字
TimesRegular normal 100,200,300,400
TimesBold bold 500,600,700,800,900

bolder 根据父元素加粗

1 p{font-weight:normal;}/*400,更粗是bold对应700,其中最小值为700*/2 p em{font-weight:bolder;}/*700*/3 4 h1{font-weight:bold;}/*700,更粗假设没有关键字,则设置为下一个更大的数字,最大为900*/5 h1 b{font-weight:bolder;}/*800*/
Copier après la connexion

font-size

  无指定数字,初始值为medium。larger类似bolder根据父元素按缩放因子上移,但无绝对大小范围(900)限制。

  百分比也是按照父元素继承的大小来计算。

  这些继承是一级一级的,嵌套越里积累越多。 

  使用px则是给字体固定值,这样有个隐患即在IE6前用户无法调整文本大小,所以字体大小使用关键字和百分数会更好。 

text-indent

  文本缩进也会继承。

1 <style type="text/css">2     #demo{text-indent:3%;}3 </style>
Copier après la connexion

1 <div id="demo">2     This is the first line.3     <p>This is the second line while this will also <br>get the text indent style.</p>4 </div>
Copier après la connexion

line-height

 1 <style type="text/css"> 2     body{font-size:10px;line-height:10px;} 3     /*由于大多数浏览器默认font-size最小值为12px,所以此处body设置的字体大小其实为12px*/ 4     5     .paragraphA{line-height:1em;}/*继承字体大小为12px,line-height为12*1=12px*/ 6     .paragraphA p{font-size:18px;}/*line-height为继承的12px*/ 7  8     .paragraphB{line-height:1;}/*使用缩放因子,运用于该元素和所有子元素,各元素根据自己字体大小值计算line-height为12*1=12px*/ 9     .paragraphB p{font-size:14px;}/*自身大小值*缩放因子:line-height为14*1=14px*/10 11     .paragraphC p{font-size:12px;line-height:150%;}/*根据自身指定字体大小计算line-height为12*150%=18px*/12 </style>
Copier après la connexion

1 <div class="paragraphA">2     <p>This is paragraph A which gets a line-height equals 12px.</p>3 </div>4 <div class="paragraphB">5     <p>This is paragraph B which gets a line-height equals 14px.</p>6 </div>7 <div class="paragraphC">8     <p>This is paragraph C which gets a line-height equals 18px.</p>9 </div> 
Copier après la connexion

vertical-align

  默认值为baseline,与文字基线对齐(字母如"g",小尾巴在基线下方)。

  text-bottom:与文字最底端那条线对齐(文字的“底部切线”,小尾巴最底端那条切线)。

  bottom:行框最底部对齐(行高大于字体大小时,行高所占空间的最底部,小尾巴下方还有一定距离)。

    百分数则是相对父元素的基线(行高)升高或者降低指定的量。

  px:正值则上升,负值则下降。

  注意vertical-align只能用于行内元素或者表单元格元素。

 

 参考资料

《css权威指南》第4~6章

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!