码迷,mamicode.com
首页 > Web开发 > 详细

CSS笔记(五)字体

时间:2015-09-29 18:49:43      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

  CSS 字体属性定义文本的字体系列、大小、加粗、风格(如斜体)和变形(如小型大写字母)。

  参考:http://www.w3school.com.cn/css/css_font.asp

  

  • CSS字体系列

5种通用字体系列:

① Serif 字体

② Sans-serif 字体

③ Monospace 字体

④ Cursive 字体

⑤ Fantasy 字体

  • 指定字体系类
p {font-family: Times, TimesNR, ‘New Century Schoolbook‘, Georgia, ‘New York‘, serif;}
  • 字体风格

常用于规定斜体文本。共三个值:normal,italic和oblique。

p.normal {font-style:normal;}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}
  • 字体变形

可设置小型大写字母。

p.normal {font-variant: normal}
p.small {font-variant: small-caps}

使用:

<p class="normal">This is a test</p>
<p class="small">This is a test</p>

效果:

技术分享

  • 字体加粗

设置文本的粗细。从100~900为字体指定了9级粗细。400对应normal,而700对应bold。

p.normal {font-weight:normal;}
p.thick {font-weight:bold;}
p.thicker {font-weight:900;}

使用:

<p class="normal">This is a test</p>
<p class="thick">This is a test</p>
<p class="thicker">This is a test</p>

效果:

技术分享

  • 字体大小

设置文本的字体大小。默认普通的默认大小为16像素(16px = 1em)。在IE中很可能要使用em设置字体大小。

h1 {font-size:60px;}
h2 {font-size:2.5em;}
p {font-size:0.875em;}

 

CSS 字体属性

属性描述
font 简写属性。作用是把所有针对字体的属性设置在一个声明中。
font-family 设置字体系列。
font-size 设置字体的尺寸。
font-size-adjust 当首选字体不可用时,对替换字体进行智能缩放。(CSS2.1 已删除该属性。)
font-stretch 对字体进行水平拉伸。(CSS2.1 已删除该属性。)
font-style 设置字体风格。
font-variant 以小型大写字体或者正常字体显示文本。
font-weight 设置字体的粗细。

CSS笔记(五)字体

标签:

原文地址:http://www.cnblogs.com/AmitX-moten/p/4846642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!