CSS字体与文本样式详解

html-css08

CSS字体与文本样式详解,第1张

学习导航

1、css中的长度与颜色

2、css中的文字属性

3、css中的文本属性

1、文字样式属性

font-family 字体属性

作用:元素内文字以什么字体来显示

语法:font-family:[字体1],[字体2],[......]

说明:含空格字体名和中文,用英文引号(")括起;多个字体用英文逗号隔开;引号嵌套,外使用双引号,内使用单引号。

font-size 文字大小

作用:元素内文字大小

语法:font-size:绝对单单位,相相对单位

color 文字颜色

语法:颜色名|十六进制|RGB

font-weight 文字粗细

语法:font-weight:normal 正常 | bold 加粗 | bolder 加粗 | lighter 细体 | 100-900

说明:默认值:normal 400等同于normal,而700等同于bold

font-style 文字样式

作用:为元素内文字设置样式

语法:font-style:normal 正常显示 | italic 文字倾斜 | oblique 文字倾斜(基本不用)

font-variant 字体变形

作用:设置元素中文本为小型大写字母

语法:font-variant:normal 正常显示| small-caps 将英文大小写字母调成为同宽

font 属性简写

语法:font:font-style font-variant  font-weight font-size/line-height font-family

说明:值之间空格隔开,注意书写顺序。

2、CSS文本样式

text-align

作用:设置元素内文本的水平对齐方式

语法:tex-align:left 左对齐 | right 右对齐 | center 居中对齐 | justify 两端对齐

注意:该属性对块级元素设置有效

line-height

作用:设置元素中文本行高

语法:line-height:长度值 | 百分比

说明:一行文字的高度,行高指文本行的基线间的距离

文字基线

注意:基线并不是汉字文字的下沿,看图理解自行理解

行高和行距

行高:基线到基线的距离

行距:底线到顶线的距离

注意:看图自行理解

行框和行内框

注意:看图自行理解

vertical-align

作用:设置元素内容的垂直方式

语法:vertical-align:baseline | sub | super | top | text-top | middle | bottom | text-bottom | 长度 | 百分比

注意:看图自行理解

text-indent 首行缩进

3、文本样式属性

text-transform: capitzlize 首字母大写 | uppercase 字母大写 | lowercase  字母小写 | none 正常

text-decoration: underline 下划线 | overline 上划线 | line-through 删除线 | none 正常

综合实操案例

如果您觉得有用,记得在下方点赞、关注、留言,我会定期奉 上更多的惊喜哦,您的打赏支持才是我继续努力的动力,么么哒。

每日分享在学习过程中总结的学习经验,学习笔记,笔试题,HTML,CSS,JavaScript,jQuery教程,Vue教程,PHP教程,TinkPHP教程等,望大家能以学习为目的,每天阅读一篇文章,了解身边的技术。陪有梦想的人一起成长!

做了一个导航横向代码里面的鼠标未移上去时的字体怎么也改不了颜色和大小

希望高手帮个忙看看怎么改CSS代码:#top1

{

WIDTH:

969px}/*---------------------页面基础定义----------------------------------*/body,td,th

{

font-family:

Tahoma,

Verdana,

Arial,

sans-serif

font-size:

12px

color:

#000000}body

{

margin-left:

0px

margin-top:

0px

margin-right:

0px

margin-bottom:

0px}/*---------------------链接定义----------------------------------*/a

{

color:

#FFFFFF

text-decoration:

none}a:hover

{

color:

#000000

text-decoration:

none}a:active{

color:

#FF0000

text-decoration:

none}/*---------------------菜单样式----------------------------------*/#menu{

height:32px

margin-top:1px

background-color:#90D311}#menu

ul{

margin:auto

width:778px

height:32px

list-style-type:none

padding:0px

margin-top:0px

margin-bottom:0px}.m_li{

float:left

width:88px

line-height:32px

text-align:center

margin-right:-2px

margin-left:-2px}.m_li

a:link{

display:block

color:#FFFFFF

width:85px}.m_line{

float:left

width:1px

height:32px

line-height:32px

/*ff下有效(图片垂直居中)*/}.m_line

img{

margin-top:expression((

32

-

this.height

)

/

2)

/*ie下有效(图片垂直居中)*/}.m_li_a{

float:left

width:85px

line-height:32px

text-align:center

padding-top:3px

font-weight:bold

background-image:url(

http://127.0.0.1/daohang/images/menu_bg.JPG

)

position:relative

height:32px

margin-top:-3px

margin-right:-2px

margin-left:-2px}.m_li_a

a{

display:block

color:#FF0000

width:85px}.smenu{

width:810x

margin:0px

auto

0px

auto

padding:0px

list-style-type:none

height:32px

FLOAT:

left}.s_li{

line-height:32px

FLOAT:

left

width:auto

display:none

height:32px

}.s_li_a{

line-height:32px

width:auto

display:block

height:32px

FLOAT:

left}