css 常用样式(分享)

2017-03-23 14:39:31 css
下面小编就为大家带来一篇css 常用样式(分享)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

font-family 设置字体名称

可以使用多个名称,用逗号分隔,浏览器则按照先后顺序依次使用可用字体

p { font-family:'宋体','黑体','Arial'; }  

font-size 设置字体大小

length 用长度值指定文字大小,不允许负值

percentage 用百分比指定文字大小,其百分比取值是基于父对象中字体的尺寸,不允许负值

p { font-size:14px;}  

font-weight 控制字体粗细

normal 正常的字体,相当于数字值400

bold 粗体,相当于数字值700

100~900 定义由细到粗的字符

p { font-weight:bold;}  

font-style 控制字体是否倾斜

normal 指定文本字体样式为正常的字体

italic 指定文本字体样式为斜体,对于没有设计斜体的特殊字体,如果要使用斜体外观将应用oblique

oblique 指定文本字体样式为倾斜的字体,人为的使文字倾斜,而不是去选取字体中的斜体字


    p { font-style: normal; }   
    p { font-style: italic; }   
    p { font-style: oblique; }  

font(字体样式缩写)
例:   
p{   
font-style: italic;   
font-weight: bold;   
font-size: 14px;   
line-height: 22px;   
font-family:'宋体';   
}   
  
缩写后:   
p { font: italic bold 14px/22px '宋体'; } 

color 文本颜色

•英文单词,比如:red,yellow,green …

•十六进制表示方式,#开头,6个十六进制的字符或数字组合,比如:#FFFFFF,#000000 …

•RGB模式,红 0-255,绿 0-255,蓝 0-255,比如:RGB(120,33,234)

•RGBA模式,比如:RGBA(255,0,0,0.5),最后的A表示透明度50%

text-decoration 文本装饰线条

none 默认。定义标准的文本

underline 定义文本下的一条线

overline 定义文本上的一条线

line-through 定义穿过文本的一条线

blink 定义闪烁的文本


    h1 {text-decoration:overline;}   
    h2 {text-decoration:line-through;}   
    h3 {text-decoration:underline;}  

text-shadow 文本阴影

h-shadow 必需。水平阴影的位置。允许负值

v-shadow 必需。垂直阴影的位置。允许负值

blur 可选。模糊的距离

color 可选。阴影的颜色

h1{ text-shadow: 2px 2px 2px #ff0000;} 

宽度 width : auto | length

高度 height : auto | length

p { width:300px;}   
div { width:50%;}   
img { height:200px;}   
div { height:100px;}

外边距 margin : auto | length

margin-top 设置上边的外边距

margin-bottom 设置下边的外边距

margin-left 设置左边的外边距

margin-right 设置右边的外边距

缩写型式:

margin: 上边距  右边距  下边距  左边距

margin: 上下边距  左右边距

margin: 上边距  左右边距  下边距

div { width:300px; height:100px; margin:10px;}   
div { width:300px; height:100px; margin:0 auto;} 

内边距 padding : length

padding-top 设置上边的内边距

padding-bottom 设置下边的内边距

padding-left 设置左边的内边距

padding-right 设置右边的内边距

div { width:300px; height:100px; padding:10px;} 

透明度 opacity : <number>

number值为 0.0-1.0 之间的小数

兼容全浏览器的写法:

div{ filter:alpha(opacity=50); }  /* IE6-IE8 */   
div{ opacity:0.5; }  /* 现代浏览器 */ 

以上这篇css 常用样式(分享)就是小编分享给大家的全部内容了,希望能给大家一个参考