font简写

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Doc</title>
<style type="text/css">
    /*
        字体属性主要包括下面几个

        font-family,font-style,font-variant,font-weight,font-size,font

        font-family(字体族): “Arial”、“Times New Roman”、“宋体”、“黑体”等;
        font-style(字体样式): normal(正常)、italic(斜体)或oblique(倾斜);
        font-variant (字体变化): normal(正常)或small-caps(小体大写字母);
        font-weight (字体浓淡): 是normal(正常)或bold(加粗)。有些浏览器甚至支持采用100到900之间的数字(以百为单位);
        font-size(字体大小): 可通过多种不同单位(比如像素或百分比等)来设置, 如:12xp,12pt,120%,1em

        如果用 font 属性的话,就可以把几个样式进行简化,减少书的情况;font 属性的值应按以下次序书写(各个属性之间用空格隔开):

        顺序:font-style | font-variant | font-weight | font-size | line-height | font-family 
当然了,前三个属性顺序可以在前三的位置中随意排列,如果有值是normal ,可以省略。
font-size 和 font-family 必须是紧跟前三个属性后面,并且一定要有。
强调: font属性必须的两个值是 font-size 和 font-family ,而且必须以这样的顺序编写,其他值都是可选的。   
*/ div { width: 100px; height: 100px; background: lightgreen; float: left; margin: 20px; font: 30px/100px "microsoft yahei"; /* font-size和line-height只能通过斜杠/组成一个值,不能分开写 */ text-align: center; } </style> </head> <body> <div>a</div> <div>b</div> <div>c</div> <div>d</div> <div>e</div> <div>f</div> <div>g</div> <div>h</div> <div>i</div> <div>j</div> <script type="text/javascript"> var divs=document.getElementsByTagName("div"); for (var i=0;i<divs.length;i++) { divs[i].onclick=(function(n){ return function(){ console.log(n); } })(i) } </script> </body> </html>

 

posted @ 2022-06-06 22:16  我歌且谣  阅读(102)  评论(0编辑  收藏  举报