css基础:样式属性

1.背景与前景:background-color:;背景色,样式表优先级高。

background-image:url(路径);设置背景图片

background-attachment:fixed;背景固定,不随字体滚动。scroll;背景随字体滚动。

background-repeat:no-repeat;不平铺。repeat;平铺。repeat-x;横向平铺。repeat-y;纵向平铺。

background-position:center 背景图居中,设置背景图时,top 上,left 左,right 右,repeat必须为no-repeat

background-position:left 100px top 200px;离左边100像素,离上边200像素。

2.字体:font-famliy:"新宋体";

font-size:12px; 字体大小,需要加单位

font-weight:bold; 加粗,normal为正常。

font-style:italic; 斜体,normal不倾斜

color:#000000; 字体颜色

text-decoration:underline;下划线,overline 上划线,line-through删除线,none 去掉下划线

text-align:center; 水平居中,left 左对齐,right 右对齐

vertical-align:middle; 垂直对齐,top 顶部对齐,bottom 底部对齐

text-indent:28px; 首行缩进量

line-height:24px; 行高,一般为1.5~2倍字体大小。

display:none; 不显示,inline-block 显示为块,不自动换行,高度可设。

visibility:hidden;可视性:隐藏,占空间;visible 显示。

3.边界和边框:border 边框线,margin 外边距,padding 内边距。

border:5px solid black;四边框,5像素宽,实线,黑色。border-top 上边框;bottom 下边框;left 左;right 右。

margin:10px;四面边框外宽度为10px;auto 居中;margin-top 顶部边框外为10px;margin:20px 0px 10px 5px  上-右-下-左边框外宽度分别为20,0,10,5px。

padding:10px:四面边框内宽度为10px;上下左右同上。

3.列表与方块:width、height、(top、bottom、left、right)只有在绝对坐标情况下才有用。

list-style:none;取消列表序号;circle 序号变为圆圈,样式相当于无序。

list-style-image:url(图片地址);图片作为序号。

list-style-position:outside;序号在内容外;inside 序号跟内容在一起。

posted @ 2017-07-24 20:30  黑眼圈的鱼  阅读(132)  评论(0编辑  收藏  举报