css字体如何设置
作者:互联网
2026-04-08
css字体设置的方法:1、h2中的大小设置em;2、字体设置需要用到【font-family】;3、字体粗细设置需要用到属性【font-weight】;4、字体样式用【font-style】属性。

本教程操作环境:windows7系统、css3版,DELL G3电脑。
css字体设置的方法:
1、字体大小设置
字体大小设置,常见的有四种不同的方法:
body{font-size:14px;}h1{font-size:150%;}h2{font-size:1.2em;}h3{font-size:small;}body中的大小设置14px,表示字体的高度是14个像素;
h1中的大小设置百分比,是表示相对大小,相对于body的150%倍;
h2中的大小设置em,是表示相对大小,想对于body的1.2倍大小;
h3中的大小直接是关键字。常用的有small,medium,large;
2、字体设置
字体设置需要用到font-family设置:
body{font-family:Verdana,Genva,Arial,sans-serif;}3、字体粗细
字体粗细设置需要用到属性font-weight设置:
body{font-weight:bold;}bold表示粗体,还有normal、bolder,lighter。也可以用数值表示。
4、字体样式
字体样式用font-style属性设置:
body{font-style:italic;}h1{font-style:oblique;}
相关推荐
