css大全

一 掌控文字

1 文字的字体设置

font-family

2 文字的字体效果

font-style  属性设置值:normal 正常体 italic 斜体 oblique 歪斜体

3 文字的粗细控制

font-weight  属性设置值:normal 正常粗细 bold 粗体 bolder 加粗体 lighter 比正常粗细还细 100-900 共有九个层次 (100,200……900),数字越大字体越粗

4 文字大小的控制

font-size 属性设置值: xx-small 极小 x-small 较小 small 小 large 标准大小 x-large 大 xx-large 较大 数值 可以使用前面所讲的尺度单位

5 文字的加线效果

text-decoration  属性设置值:none 正常显示 underline 为文字加下划线 line-through 为文字加删除线 overline 加顶线  blink 文字闪烁

 

二 精细排版

1 段落的首行缩进

text-indent  正值为右缩进  负值为凸出

margin-left  控制文本段落向右移动

2 控制字符间距

letter-spacing  加上数值使用

3 控制段落行距

line-height  也是加上数值使用

4 控制段落水平位置

text-align   属性设置值: left 左对齐,浏览器默认的 right 右对齐 center 居中对齐 段落的每一行都居中对齐 justify 整个段落居中

5 控制段落垂直位置

vertical-align  属性设置值:top middle bottom

三 矩形模块化

1 模块边界的设置

margin-top   margin-right  margin-bottom  margin-left    都用数值来设定

可单单用一个margin 表示  方向为顺时针  上 右 下 左

2 模块边框的设置

边框宽度 border-width  属性设置值: thin medium thick 数值

边框颜色 border-color

上下左右边框在中间加上top 等等 如: border-top-width  border-bottom-color ……

边框样式 border-style  属性设置值:none 浏览器默认方式 dotted 小点虚线 dashed 大点虚线 solid 实线 double 双直线 groove 3D 凹线 ridge 3D凸线 inset 3D框入线 outset 3D隆起线

3 模块内边界的设置

padding-top  padding-right  padding-bottom  padding-left 都用数值表示 可合并使用

四 网页背景颜色的设置

1 文字颜色设置  font {color:red}

2 网页背景颜色  body {background-color:red}  文字背景颜色设置 font {background-color:red}

3 文字背景图片设置  font {background-image:url(o2.gif)}    网页背景图片设置 body {backgroud-image:url:(o3.gif)}

五 背景图片的并排设置

background-repeat:repeat-x    属性设置值: repeat 背景图片铺满全页面 repeat-x 背景图片以横向并排 repeat-y 背景图片以纵向并排 no-repeat 背景图片不以并排方式显示


六 图片的固定设置

background-attachment  属性设置值:fixed 设置背景图片固定不动 scroll 设置背景图片跟着移动,这是浏览器默认的

七 图片定位设置

background-position   属性设置值:可以是 x y 的值 ,也可以是百分比 还可以是 : top left 左上位置  top center 靠上居中位置 top right 右上位置 left center  靠左居中位置 center center  正中位置  right center 靠右举重位置  bottom left 左下位置 bottom center 靠下居中位置   bottom right  右下位置

八 超链接的多样化

1 链接颜色的设置

a:link 尚未链接过的文字  a:visited  已链接过得文字 a:active 当鼠标点击时  a:hover  当鼠标移过时

a:link {color:red}

2 链接字体的变化
 
a:hover {color:green;font-family:楷体;font-size:20}  在a:hover里定义

3 链接的下划线设置

a {text-decoration:none} 


九  华丽的滚动条

body {scrollar-face-color:blue}   属性设置值:scrollar-face-color  控制滚动条以及三角按钮的表面颜色  scrollar-shadow-color 控制滚动条以及三角形按钮边缘的阴影颜色  scrollar-highlight-color  控制滚动条以及三角形按钮边框的颜色  scrollar-3dlight-color  控制滚动条以及三角按钮的3D光影颜色   scrollbar-darkshadow-color  控制滚动条以及三角按钮的3D阴影颜色 scrollar-track-color  控制滚动区域的颜色  scrollar-arrow-color  控制三角按钮中小三角形的颜色

 

background-attachment -- 背景图片随滚动轴的移动方式
background-color -- 背景颜色
background-image -- 背景图像
background-position -- 背景图片的位置
background-repeat -- 背景图片的显示方式
background -- 统一背景
border -- 统一边框所有属性
border-bottom -- 统一下边框
border-bottom-color -- 下边框颜色
border-bottom-style -- 下边框样式
border-bottom-width -- 下边框宽度
border-break -- 内容分开的边框
border-collapse
border-color -- 边框颜色
border-left -- 统一左边框
border-image -- 边框图像
border-left-color -- 左边框颜色
border-left-style -- 左边框样式
border-left-width -- 左边框宽度
border-radius -- 圆角边框
border-right-color -- 右边框颜色
border-right-style -- 右边框样式
border-right-width -- 右边框宽度
border-right -- 统一右边框
border-spacing
border-style -- 边框样式
border-top -- 统一上边框
border-top-color -- 上边框颜色
border-top-style -- 上边框样式
border-top-width -- 上边框宽度
border-width -- 统一边框宽度
bottom -- 下偏移属性
caption-side
clear -- 清除
clip -- 了盒子可显示的区域
color -- 颜色
content -- 字符串
counter-increment
counter-reset
cue-after
cue-before
cue
cursor -- 鼠标样式
direction
display -- 显示方式
elevation
empty-cells
float -- 元素漂浮
font-family -- 字体
font-size -- 字体大小
font-style -- 字体样式
font-variant -- 小型的大写字母字体
font-weight -- 字体粗细
font -- 统一字体所有属性
height -- 盒子高度
left -- 左偏移属性
letter-spacing -- 文本中字母的间距(中文为文字的间距)
line-height -- 一段文字中每行文字的间距
list-style-image -- 列表图像
list-style-position -- 列表位置
list-style-type -- 列表类型
list-style -- 统一列表所有属性
margin-right -- 右边外补白宽度
margin-left -- 左边外补白宽度
margin-top -- 上边外补白宽度
margin-bottom -- 下边外补白宽度
margin -- 统一边外补白
max-height -- 最大高度
max-width -- 最大宽度
min-height -- 最小高度
min-width -- 最小宽度
opacity -- 元素的透明度
orphans
outline-color
outline-style
outline-width
outline
overflow -- 盒子中内容的显示方式
padding-top -- 上边内补白
padding-right -- 右边内补白
padding-bottom -- 下边内补白
padding-left -- 左边内补白
padding -- 统一边内补白
page-break-after
page-break-before
page-break-inside
pause-after
pause-before
pause
pitch-range
pitch
play-during
position -- 元素的定位
quotes
richness
right -- 右偏移属性
speak-header
speak-numeral
speak-punctuation
speak
speech-rate
stress
table-layout
text-align -- 文本对齐方式
text-decoration -- 文本是否有划线以及划线的方式
text-indent -- 文本的首行缩进
text-transform -- 文本的大小写状态,此属性对中文无意义
top -- 上偏移属性
unicode-bidi
vertical-align -- 垂直对齐方式
visibility -- 元素是否可见
voice-family
volume
white-space -- 文本的格式
widows
width -- 盒子宽度
word-spacing -- 以空格间隔文字的间距
z-index -- z轴顺序


CSS 16 进制颜色表示法:
color:#ff0000;
color:#00ff00;
color:#1199ff;

通常使用background-color 定义背景颜色,background-image 定义背景图片,background-repeat定义背景图片的重复方式,background-position 定义背景图片的位置,background-attachment 定义背景图片随滚动轴的移动方式.


字体属性:(font)
大小 {font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD
样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)
行高 {line-height: normal;}(正常) 单位:PX、PD、EM
粗细 {font-weight: bold;}(粗体) lighter;(细体) normal;(正常)
变体 {font-variant: small-caps;}(小型大写字母) normal;(正常)
大小写 {text-transform: capitalize;}(首字母大写) uppercase;(大写) lowercase;(小写) none;(无)
修饰 {text-decoration: underline;}(下划线) overline;(上划线) line-through;(删除线) blink;(闪烁)

常用字体: (font-family)
"Courier New", Courier, monospace, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif, Verdana

背景属性: (background)
色彩 {background-color: #FFFFFF;}
图片 {background-image: url();}
重复 {background-repeat: no-repeat;}
滚动 {background-attachment: fixed;}(固定) scroll;(滚动)
位置 {background-position: left;}(水平) top(垂直);
简写方法 {background:#000 url(..) repeat fixed left top;} /*简写·这个在阅读代码中经常出现,要认真的研究*/

区块属性: (Block) /*这个属性第一次认识,要多多研究*/
字间距 {letter-spacing: normal;} 数值 /*这个属性似乎有用,多实践下*/
对齐 {text-align: justify;}(两端对齐) left;(左对齐) right;(右对齐) center;(居中)
缩进 {text-indent: 数值px;}
垂直对齐 {vertical-align: baseline;}(基线) sub;(下标) super;(下标) top; text-top; middle; bottom; text-bottom;
词间距word-spacing: normal; 数值
空格white-space: pre;(保留) nowrap;(不换行)

显示 {display:block;}(块) inline;(内嵌) list-item;(列表项) run-in;(追加部分) compact;(紧凑) marker;(标记) table; inline-table; table-raw-group; table-header-group; table-footer-group; table-raw; table-column-group; table-column; table-cell; table-caption;(表格标题) /*display 属性的了解很模糊*/

方框属性: (Box)
width:; height:; float:; clear:both; margin:; padding:;     顺序:上右下左
边框属性: (Border)
border-style: dotted;(点线) dashed;(虚线) solid; double;(双线) groove;(槽线) ridge;(脊状) inset;(凹陷) outset;
border-width:; 边框宽度
border-color:#;

简写方法border:width style color; /*简写*/

列表属性: (List-style)
类型list-style-type:    disc;(圆点) circle;(圆圈) square;(方块) decimal;(数字) lower-roman;(小罗码数字) upper-roman; lower-alpha; upper-alpha;
位置list-style-position: outside;(外) inside;
图像list-style-image: url(..);
定位属性: (Position)
Position: absolute; relative; static;
visibility: inherit; visible; hidden;
overflow: visible; hidden; scroll; auto;
clip: rect(12px,auto,12px,auto) (裁切)

css属性代码大全
一 CSS文字属性:
color : #999999; /*文字颜色*/
font-family : 宋体,sans-serif; /*文字字体*/
font-size : 9pt; /*文字大小*/
font-style:itelic; /*文字斜体*/
font-variant:small-caps; /*小字体*/
letter-spacing : 1pt; /*字间距离*/
line-height : 200%; /*设置行高*/
font-weight:bold; /*文字粗体*/
vertical-align:sub; /*下标字*/
vertical-align:super; /*上标字*/
text-decoration:line-through; /*加删除线*/
text-decoration: overline; /*加顶线*/
text-decoration:underline; /*加下划线*/
text-decoration:none; /*删除链接下划线*/
text-transform : capitalize; /*首字大写*/
text-transform : uppercase; /*英文大写*/
text-transform : lowercase; /*英文小写*/
text-align:right; /*文字右对齐*/
text-align:left; /*文字左对齐*/
text-align:center; /*文字居中对齐*/
text-align:justify; /*文字分散对齐*/
vertical-align属性
vertical-align:top; /*垂直向上对齐*/
vertical-align:bottom; /*垂直向下对齐*/
vertical-align:middle; /*垂直居中对齐*/
vertical-align:text-top; /*文字垂直向上对齐*/
vertical-align:text-bottom; /*文字垂直向下对齐*/
二、CSS边框空白
padding-top:10px; /*上边框留空白*/
padding-right:10px; /*右边框留空白*/
padding-bottom:10px; /*下边框留空白*/
padding-left:10px; /*左边框留空白
三、CSS符号属性:
list-style-type:none; /*不编号*/
list-style-type:decimal; /*阿拉伯数字*/
list-style-type:lower-roman; /*小写罗马数字*/
list-style-type:upper-roman; /*大写罗马数字*/
list-style-type:lower-alpha; /*小写英文字母*/
list-style-type:upper-alpha; /*大写英文字母*/
list-style-type:disc; /*实心圆形符号*/
list-style-type:circle; /*空心圆形符号*/
list-style-type:square; /*实心方形符号*/
list-style-image:url(/dot.gif); /*图片式符号*/
list-style-position: outside; /*凸排*/
list-style-position:inside; /*缩进*/
四、CSS背景样式:
background-color:#F5E2EC; /*背景颜色*/
background:transparent; /*透视背景*/
background-image : url(/image/bg.gif); /*背景图片*/
background-attachment : fixed; /*浮水印固定背景*/
background-repeat : repeat; /*重复排列-网页默认*/
background-repeat : no-repeat; /*不重复排列*/
background-repeat : repeat-x; /*在x轴重复排列*/
background-repeat : repeat-y; /*在y轴重复排列*/
指定背景位置
background-position : 90% 90%; /*背景图片x与y轴的位置*/
background-position : top; /*向上对齐*/
background-position : buttom; /*向下对齐*/
background-position : left; /*向左对齐*/
background-position : right; /*向右对齐*/
background-position : center; /*居中对齐*/
五、CSS连接属性:
a /*所有超链接*/
a:link /*超链接文字格式*/
a:visited /*浏览过的链接文字格式*/
a:active /*按下链接的格式*/
a:hover /*鼠标转到链接*/
鼠标光标样式:
链接手指 CURSOR: hand
十字体 cursor:crosshair
箭头朝下 cursor:s-resize
十字箭头 cursor:move
箭头朝右 cursor:move
加一问号 cursor:help
箭头朝左 cursor:w-resize
箭头朝上 cursor:n-resize
箭头朝右上 cursor:ne-resize
箭头朝左上 cursor:nw-resize
文字I型 cursor:text
箭头斜右下 cursor:se-resize
箭头斜左下 cursor:sw-resize
漏斗 cursor:wait
光标图案(IE6)   p {cursor:url("光标文件名.cur"),text;}
六、CSS框线一览表:
border-top : 1px solid #6699cc; /*上框线*/
border-bottom : 1px solid #6699cc; /*下框线*/
border-left : 1px solid #6699cc; /*左框线*/
border-right : 1px solid #6699cc; /*右框线*/
以上是建议书写方式,但也可以使用常规的方式 如下:
border-top-color : #369 /*设置上框线top颜色*/
border-top-width :1px /*设置上框线top宽度*/
border-top-style : solid/*设置上框线top样式*/
其他框线样式
solid /*实线框*/
dotted /*虚线框*/
double /*双线框*/
groove /*立体内凸框*/
ridge /*立体浮雕框*/
inset /*凹框*/
outset /*凸框*/
七、CSS表单运用:
文字方块
按钮
复选框
选择钮
多行文字方块
下拉式菜单 选项1选项2
八、CSS边界样式:
margin-top:10px; /*上边界*/
margin-right:10px; /*右边界值*/
margin-bottom:10px; /*下边界值*/
margin-left:10px; /*左边界值*/

CSS 属性: 字体样式(Font Style)
序号 中文说明 标记语法
1 字体样式 {font:font-style font-variant font-weight font-size font-family}
2 字体类型 {font-family:"字体1","字体2","字体3",...}
3 字体大小 {font-size:数值|inherit| medium| large| larger| x-large| xx-large| small| smaller| x-small| xx-small}
4 字体风格 {font-style:inherit|italic|normal|oblique}
5 字体粗细   {font-weight:100-900|bold|bolder|lighter|normal;}
6 字体颜色   {color:数值;}
7 阴影颜色 {text-shadow:16位色值}
8 字体行高   {line-height:数值|inherit|normal;}
9 字 间 距   {letter-spacing:数值|inherit|normal}
10 单词间距 {word-spacing:数值|inherit|normal}
11 字体变形 {font-variant:inherit|normal|small-cps }
12 英文转换 {text-transform:inherit|none|capitalize|uppercase|lowercase}
13 字体变形 {font-size-adjust:inherit|none}
14 字体 {font-stretch:condensed|expanded|extra-condensed|extra-expanded|inherit|narrower|normal| semi-condensed|semi-expanded|ultra-condensed|ultra-expanded|wider}
文本样式(Text Style)
序号 中文说明 标记语法
1 行 间 距 {line-height:数值|inherit|normal;}
2 文本修饰 {text-decoration:inherit|none|underline|overline|line-through|blink}
3 段首空格   {text-indent:数值|inherit}
4 水平对齐 {text-align:left|right|center|justify}
5 垂直对齐 {vertical-align:inherit|top|bottom|text-top|text-bottom|baseline|middle|sub|super}
6 书写方式 {writing-mode:lr-tb|tb-rl}
背景样式
序号 中文说明 标记语法
1 背景颜色 {background-color:数值}
2 背景图片 {background-image: url(URL)|none}
3 背景重复 {background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
4 背景固定 {background-attachment:fixed|scroll}
5 背景定位 {background-position:数值|top|bottom|left|right|center}
6 背影样式 {background:背景颜色|背景图象|背景重复|背景附件|背景位置}
框架样式(Box Style)
序号 中文说明 标记语法
1 边界留白 {margin:margin-top margin-right margin-bottom margin-left}
2 补  白 {padding:padding-top padding-right padding-bottom padding-left}
3 边框宽度 {border-width:border-top-width border-right-width border-bottom-width border-left-width}  
宽度值: thin|medium|thick|数值
4 边框颜色 {border-color:数值 数值 数值 数值}  数值:分别代表top、right、bottom、left颜色值
5 边框风格 {border-style:none|hidden|inherit|dashed|solid|double|inset|outset|ridge|groove}
6 边  框 {border:border-width border-style color}
   上 边 框 {border-top:border-top-width border-style color}
   右 边 框 {border-right:border-right-width border-style color}
   下 边 框 {border-bottom:border-bottom-width border-style color}
   左 边 框 {border-left:border-left-width border-style color}
7 宽  度 {width:长度|百分比| auto}
8 高  度 {height:数值|auto}
9 漂  浮 {float:left|right|none}
10 清  除 {clear:none|left|right|both}
分类列表
序号 中文说明 标记语法
1 控制显示 {display:none|block|inline|list-item}
2 控制空白 {white-space:normal|pre|nowarp}
3 符号列表 {list-style-type:disc|circle|square|decimal|lower-roman|upper-roman|lower-alpha|upper-alpha|none}
4 图形列表 {list-style-image:URL}
5 位置列表 {list-style-position:inside|outside}
6 目录列表 {list-style:目录样式类型|目录样式位置|url}
7 鼠标形状 {cursor:hand|crosshair|text|wait|move|help|e-resize|nw-resize|w-resize|s-resize|se-resize|sw-resize}

分类:

  CSS真是伟大,能化一为万。假如你有几段文字,每一段都要这样:将第一行设成黄色,第二行设成红色,第三行设成蓝色,第四行设成绿色……其实这很容易做到。你在CSS中如下为每一行定义一个类。

  P.first {color:yellow} P.second {color:red} P.third {color:blue} P.fourth {color:green} 依次定义下去。在你的HTML代码中就是这样使用以上的定义类。

这里是第二行,使用的是class=secont

这里是第三行,使用的是class=third

这里是第四行,使用的是class=fourth

 ■ 更灵活的分类:
  在上面我们定义的类是前面都有一个 P,也就限定了这个类只限于
标记使用。如果我们在定义的时候去掉 P, 但 . 仍然要。比如:.first {color:yellow},这样定义的类更加灵活,可应用于任何HTML标签,例如:

 ■ 选择符 ID:

  其实CLASS只是一个类的选择符,另一个选择符 ID 具有同样的功能。不过使用ID选择符的类定义的时候要将 . 换成 # ,使用时要在类别名上加上引号。

在H2标记中使用class=first

H1 #001 {color:red}
#002 {color:blue}
使用:

H1标记使用#001类

H3标记使用#002类

P标记使用#002类

■ 字间距:

  利用字间距属性word-spacing,可以调整单词间的距离。

h2 {word-spacing:5pt}
 ■ 字母间距:
  利用字母间距属性letter-spacing,可以调整单词中每个字母间的距离。

h2 {letter-spacing:10pt};
 ■ 行高:
  与字距不同的是行距line-height,它调整的是行与行间垂直方向的距离,有三种方法设置:

数值:h3 {font-size:12pt; line-height:2};/*此处line-height=2x12pt=24pt */
长度单位:h3 {font-size:12pt; line-height:24pt};
比例:h3 {font-size:12pt; line-height:200%};
  无论是字距或字母间距或行距都有一个共同的参数:normal,一旦设为normal就是要浏览器使用默认值。

这里是第一行,使用的是class=first

■ FONT-FAMILY属性:

  每部机器上都装有多种字体,浏览器会使用默认的字体浏览网页,比如简体中文版WINDOWS汉字默认是宋体,英文默认是ARIAL。 使用FONT-FAMILY属性则可以规定浏览器用什么字体解读网页。

 ■ FONT-FAMILY语法实例:
h2 {font-family:times,impact,sans-serif}

说明如下:

  helvetica是浏览器首先寻找的字体名称,如果有就使用它。在helvetica字体没有找到的情况下,则会寻找impact字体,如果找到就使用它。如果以上两种字体都没有找到,则指示浏览使用sans-serif(通用字体)。在你不能保证你列出的字体浏览者一定会安装时,将一种通用字体加在字体列表中是一种好的做法。因此我们提倡使用最基本的字体制作网页,比如中文用宋体,英文用ARIAL,这样使得你的网页不会因为浏览器没能使用合适的字体解读而变样。

■ 其它相关内容:

通用字体有以下几类,其中cursive和fantasy不被NC支持:
"serif"(比如Times);
"sans-serif"(比如Helvetica);
"cursive"(比如Comic Sans);
"fantasy"(比如Western);
"monospace"(比如Courier)
其他使用事项:
如果一种字体的名称中有空格,如"Times New Roman",在CSS语句中要用引号包含该字体。
例:Body {font-family:"Times New Roman",serif}
如果该语句已在双引号里,则字体名降级为单引号。
例:


如果该语句包括其它CSS规则,字体说明应放在最后。
例:H2 {color:red;margin:10px;font-family:"Times New Roman",serif}
■ 继承:

  继承:就是在子元素没有定义样式的情况下,它将采用上一级元素的样式定义。

  优先级:根据继承来理解优先级也就容易。最近的样式优先级最高。 比如:

  CSS在声明 I{font-family:impact};

  但在HTML语句中又如下定义:


  ■ 更好的方法--关联:

  我并讲不出抛弃FONT标记的理由,只知道这是潮流。显然CSS提供更好的方法避免你在像上面的例子一样使用FONT标记,那就是: 关联。 可以在HEAD部分的CSS定义中加入如下行: P I {font-family:times} /*P和I之间的空格不能少*/

  在HTML中:


  虽然你没有使用FONT FACE,但根据HEAD部分的CSS定义,P标记里的I标记使用的字体一定是TIMES。要提起注意的是那行CSS样式只作用于P标记里的I标记。

■ 大小控制方法:

  以下是控制文字大小的三种方法:

使用大小单位,pt(点),px(像素),em,及其他单位;
使用关键字(xx-small,x-small,small,medium,large,x-large,xx-large);
使用比例参数(150%等)。
例如:

p {font-size:12pt};
p {font-size:large};
p {font-size:200%};
 ■ 字体风格:
斜体 p {font-style:italic};
粗体 p {font-weight:bold};
  在字重的设定方面,还有lighter(更轻)和bolder(更重),还可以使用数字100,200到900最重。

  字体风格和字重都有一个共同的参数normal,一旦设为normal也就取消了字重和风格设置。

■ FONT-VARIANT:

  FONT-VARIANT 可以将正常文字尺寸缩小一半后转为大写:

h2 {font-variant:small-caps}
 ■ TEXT-TRANSFORM:
  完全控制字母大小写:

全部大写:h2 {text-transform:uppercase};
全部小写:h2 {text-transform:lowercase};
单词第一个字母大写:h2 {text-transform:capitalie};
取消所有设定:h2 {text-transform:none};
 ■ TEXT-DECORATION:
  哪天你突发奇想,希望链接没有下划线,现在你可以做到:

文字下划线:A:link{text-decoration:underline};
文字上划线:A:link{text-decoration:overline};
文字删除线:A:link{text-decoration:line-through};
文字闪烁:A:link{text-decoration:blink};
不要任何效果:A:link{text-decoration:none}


■ 水平对齐:

  利用文字对齐属性text-align,可以控制段落的水平对齐:

h2 {text-align:center}
h2 {text-align:left}
h2 {text-align:right}
  这项属性可作用于


 ■ 垂直对齐:
  利用垂直对齐属性vwrtical-align,可以控制对象(包括文字或图形)相对于母体的垂直位置:

h2 {vertical-align:top}
h2 {vertical-align:text-top}
h2 {vertical-align:bottom}
h2 {vertical-align:text-bottom}
h2 {vertical-align:baseline}
h2 {vertical-align:middle}
h2 {vertical-align:sub}/*上标*/
h2 {vertical-align:super}/*下标*/
  这些属性具体对齐效果如何,希望大家自已去试验。

 ■ 首行缩进:
  首行缩进text-indent,在文档排版中经常用到:

h3 {text-indent:24pt};

■ 容器的概念:

  根据CSS对网页样式的定义,页面上的所有元素都放在一个容器里,这个容器叫BOX。BOX也就包括:

元素本身;
围绕元素的空格;(padding)
围绕元素空格外的边框;(border)
边框外的边距。(margin)
 ■ 四个边距:
  margin用于设定上,右,下,左,边距:

body {margin-top:10px;margin-right:20px;margin-bottom:30px;margin-left:40px}
body {margin:10px 20px 30px 40px}/*效果与上面方式相同*/
  以上参数值同样可以是其他长度单位(如:pt,em等)或比例。

 ■ 顶,底,左,右空格填充:
  padding用于设置空格填充范围,用法与边距属性相同:

h3 {margin-top:10px;margin-right:20px;margin-bottom:30px;margin-
left:40px};
h3 {margin:10px 20px 30px 40px}
 ■ 边框:
  border可设定的属性很多,包括颜色和宽度,关键是可以指定每个边的宽度和每个边的颜色 。

边框宽度border-width可以是thin,medium,thick或长度值:
h3 {border-top-width:2px;border-right-width:4px;border-bottom-width:6px;border-left-width:8px};
h3 {border-width:2px 4px 6px 8px}/*与上面相同*/

p {border-top-width:thin;border-right-width:medium;border-bottom-
width:thick;border-left-width:none};
p {border-width:thin medium thick none}/*与上面相同,左边框将不显示*/

边框颜色border-color定义方法与宽度定义相似,颜色值也可以用RGB值(如#ff00ff):
h3 {border-color:red blue yellow green}/*上:红;右:蓝;下:黄;左:绿*/
h3 {border-color:red blue }/*上,下:红;右,左:蓝;*/
h3 {border-color:#ff00ff }/*所有边框为#ff00ff色*/

边框线的线条式样border-style,有九个关键字来描述:
none /*不画边框,不论边框厚度是多少*/
dotted /*由点组成的虚线*/
dash /*由短线组成的虚线*/
solid /*实线 */
double /*双实线*/
groove /*3D沟状*/
ridge /*3D脊状*/
inset /*3D内嵌*/
outset /*3D外嵌*/
其使用方法与厚度、颜色相似,不再多讲。

一条边框的颜色,厚度,线条式样可以在一条语句中定义。例:
h1 {border-top:5px solid red}
  这么多的参数,这么多的组合,要想得心应手,不下一番功夫去练习是不可能达到的。 

■ 背景颜色:

  background-color,用它可以指定整个网页的背景颜色,也可以是某一个单词。在传统的HTML中要将背景颜色应用到一段文字上是一件麻烦事,要将文字放在表格中再设置表格的背景。CSS使之变得非常容易。

  P.colorback {background-color:#ff0000}

  颜色可以是颜色名(如red)、十六进制数(如#ff0000)、RGB值(如RGB(255,0,0))。

■ 背景图片:

  background-image,用它可以指定整个网页的背景图片(将它放在BODY标签内),也可以是某一个单词。

background-repeat 是否循环背景
p {background-repeat:no-repeat;background-image:url(background.gif)}/*不循环*/
p {background-repeat:repeat;background-image:url(background.gif)}/*循环*/
background-attachment 是否固定背景
body {background-attachment:scroll;background-image:url(background.gif)}/*随文字一起滚动*/
body {background-attachment:fixed;background-image:url(background.gif)}/*固定不动*/
  P.colorback {background-color:#ff0000}

  颜色可以是颜色名(如red)、十六进制数(如#ff0000)、RGB值(如RGB(255,0,0))。

 ■ 背景定位:

  background-position用于设置背景的位置:

p {background-position:top;background-image:url(background.gif)};

  background-position其参数可以是关键字、长度数、比例值。

关键字;
top /*背景图像与前景对象的顶部对齐*/
bottom /*背景图像与前景对象的底部对齐*/
left /*背景图像与前景对象的左边对齐*/
right /*背景图像与前景对象的右边对齐*/
center /*与前面四个任一个组合,变成水平或垂直居中*/

长度数;
可以是任何一种以前学过的长度单位(pt,px,ems...),例如:
p{background-position:100px 50px;
background-image:url(background.gif)}表示从左上角起水平100像素,垂直50像素的位置摆放。

比例值;
例如:p{background-position:85% 50%;
background-image:url(background.gif)}
表示从距离段落的右边85%,垂直距离段落顶端50%的位置摆放。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值