网页设计中的CSS样式代码详解
常用CSS代码大全(工作必备)

常用CSS代码大全(工作必备)用html+css可以很方便的进行网页的排版布局,但不是每一种属性或者代码我们都铭记于心,最近我把CSS中的常用代码进行了归纳总结,方便自己以后查看,同时也分享给大家,希望对你们有用。
一.文本设置1、font-size: 字号参数2、font-style: 字体格式3、font-weight: 字体粗细4、颜色属性 color:参数注意使用网页安全色二、超链接设置text-decoration: 参数主要目的是在浏览器显示文本链接时更改下划线。
参数取值范围:underline:为文字加下划线overline:为文字加上划线line-through:为文字加删除线blink:使文字闪烁none:不显示上述任何效果三、背景1、背景颜色 padding: 0px 0px 0px 10px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(61, 70, 77); font-size: 16px; border-left: 1px solid rgb(128, 128, 128); background: rgb(238, 238, 238); box-shadow: rgba(7, 17, 27, 0.05) 0px 4px 8px 0px; box-sizing: border-box; border-radius: 8px; font-family: "Helvetica Neue", Helvetica, "PingFang SC", 微软雅黑, Tahoma, Arial, sans-serif;">2、背景图片background-image: url(URL)URL就是背景图片的存放路径,none表示无。
3、背景图片重复 background-repeat: 参数参数取值范围:no-repeat:不重复平铺背景图片repeat-x:使图片只在水平方向上平铺repeat-y:使图片只在垂直方向上平铺如果不指定背景图像重复属性,浏览器默认水平和垂直平铺背景图像。
css 常用格式化样式

css常用格式化样式CSS(层叠样式表)用于设计和格式化网页的外观和样式。
下面是一些常用的格式化样式:1.文本格式化:●修改字体:font-family:Arial,sans-serif;●修改字体大小:font-size:16px;●修改字体粗细:font-weight:bold;●修改字体颜色:color:#333;●修改行高:line-height:1.5;●修改文字对齐方式:text-align:center;2.盒子模型格式化:●修改元素的宽度和高度:width:200px;height:100px;●设置边框:border:1px solid#ccc;●设置内边距:padding:10px;●设置外边距:margin:20px;●设置元素的背景颜色:background-color:#f5f5f5;3.背景格式化:●设置背景图片:background-image:url('example.jpg');●背景图片重复方式:background-repeat:no-repeat;●背景图片位置:background-position:center center;●背景图片大小:background-size:cover;4.元素定位:●设置元素相对定位:position:relative;●设置元素绝对定位:position:absolute;●元素位置:top:50px;left:20px;5.清除浮动:●清除浮动:.clearfix::after{content:"";display:table;clear:both;}6.响应式设计:●媒体查询:@media screen and(max-width:600px){在小屏幕下的样式body{font-size:14px;}}这些是一些常见的CSS格式化样式,用于调整文本、盒子模型、背景、定位和响应式设计等方面的样式。
css颜色代码大全

css颜色代码大全CSS颜色代码大全。
在网页设计中,颜色的运用是非常重要的,它能够直接影响到用户的视觉体验和情绪感受。
而在CSS中,我们常常需要用到颜色代码来定义元素的颜色。
本文将为大家详细介绍CSS中常用的颜色代码,希望能够帮助大家更好地运用颜色来设计网页。
一、RGB颜色代码。
RGB颜色代码是由红(Red)、绿(Green)、蓝(Blue)三种颜色按照不同的比例混合而成的,每种颜色的取值范围是0-255。
在CSS中,我们可以使用rgb()函数来定义颜色,例如:```css。
div {。
background-color: rgb(255, 0, 0); / 红色 /。
}。
```。
二、十六进制颜色代码。
除了使用RGB颜色代码外,我们还可以使用十六进制颜色代码来表示颜色。
它由井号(#)和6位十六进制数组成,前两位表示红色分量,中间两位表示绿色分量,最后两位表示蓝色分量。
例如:```css。
div {。
background-color: #ff0000; / 红色 /。
}。
```。
三、颜色关键字代码。
在CSS中,还有一些颜色关键字可以直接使用,比如red、green、blue等。
这些颜色关键字代表了常见的颜色,使用起来非常方便。
例如:```css。
div {。
color: red; / 红色 /。
}。
```。
四、HSL颜色代码。
HSL颜色代码是由色相(Hue)、饱和度(Saturation)、亮度(Lightness)三个参数来定义颜色的,它能够更直观地表示颜色。
在CSS中,我们可以使用hsl()函数来定义颜色,例如:```css。
div {。
background-color: hsl(0, 100%, 50%); / 红色 /。
}。
```。
五、透明度。
除了定义颜色外,我们还可以使用rgba()函数来定义带有透明度的颜色。
其中,最后一个参数表示透明度,取值范围是0-1。
例如:```css。
div {。
css教程菜鸟

css教程菜鸟CSS(层叠样式表)是一种用于描述网页上的元素布局和样式的语言,它能够使网页更加美观和易于阅读。
本文将介绍一些CSS的基础知识和常用属性,以帮助菜鸟入门。
首先,让我们了解一下CSS的基本语法。
CSS由选择器和声明块组成。
选择器指定了要应用样式的HTML元素,而声明块则包含了一系列属性-值对,用于描述要应用到元素上的样式。
下面是一个简单的示例:```p {color: red;font-size: 20px;}```上述代码中,选择器“p”表示要应用样式的HTML段落元素。
声明块中的属性-值对指定了段落的文本颜色为红色,字体大小为20像素。
接下来,我们将介绍一些常用的CSS属性。
1. 字体属性:用于设置文本的字体样式,如字体大小、字体族等。
例如:```p {font-size: 16px;font-family: Arial, sans-serif;}```上述代码将段落的字体大小设置为16像素,字体族为Arial或者sans-serif。
2. 背景属性:用于设置元素的背景样式,如背景颜色、背景图片等。
例如:```body {background-color: lightblue;background-image: url("bg.jpg");}```上述代码将页面的背景颜色设置为浅蓝色,背景图片为名为“bg.jpg”的图片。
3. 边框属性:用于设置元素的边框样式,如边框宽度、边框颜色等。
例如:```div {border: 1px solid black;}```上述代码将`<div>`元素的边框宽度设置为1像素,边框颜色为黑色。
4. 盒模型属性:用于调整元素的尺寸和定位,如元素的宽度、高度、外边距等。
例如:```img {width: 200px;height: 150px;margin-top: 10px;}```上述代码将图片的宽度设置为200像素,高度设置为150像素,并且向上外边距10像素。
DIV+CSS网页设计常用布局代码

DIV+CSS⽹页设计常⽤布局代码01. 单⾏⼀列02.03. body{margin:0px;padding:0px;text-align:center;}04. #content{margin-left:auto;margin-right:auto;width:400px;width:370px;}05.06. 两⾏⼀列07.08. body{margin:0px;padding:0px;text-align:center;}09. #content-top{margin-left:auto;margin-right:auto;width:400px;width:370px;}10. #content-end{margin-left:auto;margin-right:auto;width:400px;width:370px;}11.12. 三⾏⼀列13.14. body{margin:0px;padding:0px;text-align:center;}15. #content-top{margin-left:auto;margin-right:auto;width:400px;width:370px;}16.17. #content-mid{margin-left:auto;margin-right:auto;width:400px;width:370px;}18. #content-end{margin-left:auto;margin-right:auto;width:400px;width:370px;}19.20. 单⾏两列21.22. #bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}23. #bodycenter#dv1{float:left;width:280px;}24. #bodycenter#dv2{float:right;width:410px;}25.26. 两⾏两列27.28. #header{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}29. #bodycenter{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}30.31.32. #bodycenter#dv1{float:left;width:280px;}33. #bodycenter#dv2{float:right;width:410px;}34.35. 三⾏两列36.37. #header{width:700px;margin-right:auto;margin-left:auto;}38. #bodycenter{width:700px;margin-right:auto;margin-left:auto;}39. #bodycenter#dv1{float:left;width:280px;}40. #bodycenter#dv2{float:right;width:410px;}41. #footer{width:700px;margin-right:auto;margin-left:auto;overflow:auto;}42. //43.44. 单⾏三列绝对定位45.46. #left{position:absolute;top:0px;left:0px;width:120px;}47. #middle{margin:20px190px20px190px;}48. #right{position:absolute;top:0px;right:0px;width:120px;}49.50. float定位⼀51. xhtml:52.53. <divid="warp"><divid="column"><divid="column1">这⾥是第⼀列</div><divid="column2">这⾥是第⼆列</div><divclass="clear"></div></div><divid="column3">这⾥是第三列</div><divclass="clear"></div></div>54.55. CSS:56.57. #wrap{width:100%;height:auto;}58. #column{float:left;width:60%;}59. #column1{float:left;width:30%;}60. #column2{float:right;width:30%;}61. #column3{float:right;width:40%;}62. .clear{clear:both;}63.64. float定位⼆65. xhtml:66. <divid="center"class="column"><h1>Thisisthemaincontent.</h1></div><divid="left"class="column"><h2>Thisistheleftsidebar.</h2></div><divid="right"class="column"><h2>Thisistherightsidebar.</h2></div>67.68. CSS:69.70. body{margin:0;padding-left:200px;padding-right:190px;min-width:240px;}71. .column{position:relative;float:left;}72. #center{width:100%;}73. #left{width:180px;right:240px;margin-left:-100%;}74. #right{width:130px;margin-right:-100%;}75.76. 两⾏三列77. xhtml:<divid="header">这⾥是顶⾏</div><divid="warp"><divid="column"><divid="column1">这⾥是第⼀列</div><divid="column2">这⾥是第⼆列</div><divclass="clear"></div></P><P></div><divid="column3">这⾥是第三列</div><divclass="clear"></div></div>78.79. CSS:80.81. #header{width:100%;height:auto;}82. #wrap{width:100%;height:auto;}83. #column{float:left;width:60%;}84. #column1{float:left;width:30%;}85. #column2{float:right;width:30%;}86. #column3{float:right;width:40%;}87. .clear{clear:both;}88.89. 三⾏三列90. xhtml:91. <divid="header">这⾥是顶⾏</div><divid="warp"><divid="column"><divid="column1">这⾥是第⼀列</div><divid="column2">这⾥是第⼆列</div><divclass="clear"></div></div><divid="column3">这⾥是第三列</div><divclass="clear"></div></div><divid="footer">这⾥是底部⼀⾏</div>92.93. CSS:94.95. #header{width:100%;height:auto;}96. #wrap{width:100%;height:auto;}97. #column{float:left;width:60%;}98. #column1{float:left;width:30%;}99. #column2{float:right;width:30%;}100. #column3{float:right;width:40%;}101. .clear{clear:both;}102. #footer{width:100%;height:auto;}。
css常用代码大全

字体属性:(font)大小 {font-size: *-large;}(特大) **-small;(极小) 一般中文用不到,只要用数值就可以,单位:P*、PD样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)行高 {line-height: normal;}(正常) 单位:P*、PD、EM粗细 {font-weight: bold;}(粗体) lighter;(细体) normal;(正常)变体 {font-variant: small-caps;}(小型大写字母) normal;(正常)大小写{te*t-transform: capitalize;}(首字母大写) uppercase;(大写) lowercase;(小写)none;(无)修饰{te*t-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: fi*ed;}(固定) scroll;(滚动)位置 {background-position: left;}(水平) top(垂直);简写方法 {background:#000 url(..) repeat fi*ed left top;} /*简写·这个在阅读代码中经常出现,要认真的研究*/区块属性: (Block) /*这个属性第一次认识,要多多研究*/字间距 {letter-spacing: normal;} 数值 /*这个属性似乎有用,多实践下*/ 对齐 {te*t-align: justify;}(两端对齐) left;(左对齐) right;(右对齐)center;(居中)缩进 {te*t-indent: 数值p*;}垂直对齐 {vertical-align: baseline;}(基线) sub;(下标) super;(下标) top; te*t-top;middle; bottom; te*t-bottom;词间距word-spacing: normal; 数值空格white-space: pre;(保存) nowrap;(不换行)显示 {display:block;}(块) inline;(嵌) list-item;(列表项) run-in;(追加局部)pact;(紧凑) 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 属性的了解很模糊*/方框属性: (Bo*)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(12p*,auto,12p*,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; /*上标字*/te*t-decoration:line-through; /*加删除线*/te*t-decoration: overline; /*加顶线*/te*t-decoration:underline; /*加下划线*/te*t-decoration:none; /*删除下划线*/te*t-transform : capitalize; /*首字大写*/te*t-transform : uppercase; /*英文大写*/te*t-transform : lowercase; /*英文小写*/te*t-align:right; /*文字右对齐*/te*t-align:left; /*文字左对齐*/te*t-align:center; /*文字居中对齐*/te*t-align:justify; /*文字分散对齐*/vertical-align属性vertical-align:top; /*垂直向上对齐*/vertical-align:bottom; /*垂直向下对齐*/vertical-align:middle; /*垂直居中对齐*/vertical-align:te*t-top; /*文字垂直向上对齐*/ vertical-align:te*t-bottom; /*文字垂直向下对齐*/ 二、CSS边框空白padding-top:10p*; /*上边框留空白*/padding-right:10p*; /*右边框留空白*/padding-bottom:10p*; /*下边框留空白*/padding-left:10p*; /*左边框留空白三、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 : fi*ed; /*浮水印固定背景*/ background-repeat : repeat; /*重复排列-网页默认*/ background-repeat : no-repeat; /*不重复排列*/ background-repeat : repeat-*; /*在*轴重复排列*/ background-repeat : repeat-y; /*在y轴重复排列*/指定背景位置background-position : 90% 90%; /*背景图片*与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:te*t箭头斜右下 cursor:se-resize箭头斜左下 cursor:sw-resize漏斗 cursor:wait光标图案(IE6) p {cursor:url("光标文件名.cur"),te*t;} 六、CSS框线一览表:border-top : 1p* solid #6699cc; /*上框线*/border-bottom : 1p* solid #6699cc; /*下框线*/border-left : 1p* solid #6699cc; /*左框线*/border-right : 1p* solid #6699cc; /*右框线*/以上是建议书写方式,但也可以使用常规的方式如下:border-top-color : #369 /*设置上框线top颜色*/border-top-width :1p* /*设置上框线top宽度*/border-top-style : solid/*设置上框线top样式*/其他框线样式solid /*实线框*/dotted /*虚线框*/double /*双线框*/groove /*立体凸框*/ridge /*立体浮雕框*/inset /*凹框*/outset /*凸框*/七、CSS表单运用:文字方块按钮复选框选择钮多行文字方块下拉式菜单选项1选项2八、CSS边界样式:margin-top:10p*; /*上边界*/margin-right:10p*; /*右边界值*/margin-bottom:10p*; /*下边界值*/margin-left:10p*; /*左边界值*/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| *-large| **-large|small| smaller| *-small| **-small}4 字体风格 {font-style:inherit|italic|normal|oblique}5 字体粗细 {font-weight:100-900|bold|bolder|lighter|normal;}6 字体颜色 {color:数值;}7 阴影颜色 {te*t-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 英文转换{te*t-transform:inherit|none|capitalize|uppercase|lowercase}13 字体变形 {font-size-adjust:inherit|none}14 字体 {font-stretch:condensed|e*panded|e*tra-condensed|e*tra-e*panded|inherit|narrower|normal| semi-condensed|semi-e*panded|ultra-condensed|ultra-e*panded|wider}文本样式(Te*t Style)序号中文说明标记语法1 行间距 {line-height:数值|inherit|normal;}2 文本修饰{te*t-decoration:inherit|none|underline|overline|line-through|blink}3 段首空格 {te*t-indent:数值|inherit}4 水平对齐 {te*t-align:left|right|center|justify}5 垂直对齐 {vertical-align:inherit|top|bottom|te*t-top|te*t-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-*|repeat-y}4 背景固定 {background-attachment:fi*ed|scroll}5 背景定位 {background-position:数值|top|bottom|left|right|center}6 背影样式 {background:背景颜色|背景图象|背景重复|背景附件|背景位置} 框架样式(Bo* 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-widthborder-left-width}宽度值: thin|medium|thick|数值4 边框颜色 {border-color:数值数值数值数值} 数值:分别代表top、right、bottom、left颜色值5 边框风格 {border-style:none|hidden|inherit|dashed|solid|double|inset|outset|ridge|groo ve}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|te*t|wait|move|help|e-resize|nw-resize|w-resize|s-resize|se-resize|sw-resize}CSS属性大全[背景]属性共有六项:「背景颜色」〔background-color〕,设置背景颜色。
css样式模板代码

css样式模板代码在网页设计中,样式模板是非常重要的一部分。
它们决定了网页的外观和布局,帮助我们创建一个美观、易于导航和易于阅读的网站。
CSS样式模板是一种复用性较高的代码,能够快速而方便地为网站添加样式,而且也可以通过修改来改变网站的整体风格。
本文将介绍一些常见的CSS样式模板代码,供大家参考。
1.导航菜单导航菜单是网站的核心组成部分之一,要让用户快速找到他们想要的内容。
以下是一个简单的CSS样式模板,可以用来创建一个水平导航菜单。
```ul {list-style-type: none;margin: 0;padding: 0;overflow: hidden;background-color: #333; }li {float: left;}li a {display: block;color: white;text-align: center;padding: 14px 16px;text-decoration: none; }li a:hover {background-color: #111; }```使用这个样式模板,我们可以在HTML中创建一个无序列表,并添加相应的链接来创建一个简单的导航菜单。
然后,为这个无序列表添加CSS样式,使它呈现出一个黑色背景和白色的字体。
当用户悬停在链接上时,链接的背景将变成深灰色,以给用户某种反馈。
2.按钮按钮是网站中的另一个重要元素,通常用于触发某种操作,例如提交表单或打开模态窗口。
以下是一个可以用来创建漂亮按钮的CSS样式模板。
```.button {background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;margin: 4px 2px;cursor: pointer;}```用这个样式模板,我们可以在HTML中创建一个按钮,并添加相应的链接来触发事件。
css的三种使用方式

css的三种使用方式CSS的三种使用方式CSS(层叠样式表)是用于描述网页样式的语言,可以实现对网页的布局和样式的控制。
在使用CSS时,有三种常见的方式:内联样式、内部样式表和外部样式表。
一、内联样式内联样式是将CSS样式直接写在HTML标签的style属性中,它的优先级最高,会覆盖其他方式设置的样式。
使用内联样式的语法如下:```html<p style="color: red; font-size: 16px;">这是一段红色字体,字号为16px的文字。
</p>```内联样式的优点是简单快捷,适合对单个标签进行样式设置。
但是,当需要对多个标签设置相同的样式时,就显得非常繁琐和冗余了。
二、内部样式表内部样式表是将CSS样式写在HTML文档的<head>标签内的<style>标签中,使用内部样式表可以对整个HTML文档中的标签进行样式设置。
使用内部样式表的语法如下:```html<head><style>p {color: blue;font-size: 14px;}</style></head><body><p>这是一段蓝色字体,字号为14px的文字。
</p></body>```内部样式表的优点是可以在同一个HTML文档中集中管理样式,方便维护和修改。
但是,当需要在多个HTML文档中使用相同的样式时,就需要重复地将内部样式表复制到每个HTML文档中,这样会造成代码的冗余。
三、外部样式表外部样式表是将CSS样式写在一个独立的CSS文件中,然后在HTML 文档中通过<link>标签引入该CSS文件,使用外部样式表可以实现样式的重用。
使用外部样式表的语法如下:```html<head><link rel="stylesheet" href="style.css"></head><body><p>这是一段样式来自外部样式表的文字。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CSS 背景属性属性描述值IE F N W3C background 简写属性,作用是将背景属性设置在一个声明中。
background-color background-imagebackground-repeat background-attachmentbackground-position4161background-attachment背景图像是否固定或者随着页面的其余部分滚动。
scrollfixed4 1 6 1background-color设置元素的背景颜色。
color-rgb color-hex color-nametransparent 4 1 4 1background-image把图像设置为背景。
urlnone 4 1 4 1background-position设置背景图像的起始位置。
top left top center top right center left center center center right bottom left bottom center bottom right x-% y-%x-pos y-pos 4 1 6 1background-repeat 设置背景图像是否及如何重复。
repeat repeat-x repeat-yno-repeat4141CSS 边框属性 (border)border-bottom简写属性。
作用是在一个声明中用来设置下边框的所有属性。
∙ border-bottom-w idthborder-styleborder-color 4 1 6 1border-bottom-color 设置下边框的颜色。
border-color 4 1 6 2 border-bottom-style 设置下边框的样式。
border-style 4 1 6 2 border-bottom-width设置下边框的宽度。
thin medium thicklength 4141border-color设置四个边框的颜色,可以设置一到四个颜色。
color4161border-left简写属性。
用于在一个声明中设置左边框的所有属性。
border-left-widthborder-styleborder-color 4 1 6 1border-left-color 设置左边框的颜色。
border-color 4 1 6 2 border-left-style 设置左边框的样式。
border-style 4 1 6 2 border-left-width设置左边框的宽度。
thin medium thicklength4141border-right简写属性。
将所有用于右边框的属性设置于一个声明中。
∙ border-right-wi dthborder-styleborder-color 4161border-right-color 设置右边框的颜色 border-color 4 1 6 2 border-right-style 设置右边框的样式 border-style 4 1 6 2 border-right-width设置右边框的宽度。
thin medium thicklength 4141border-style设置四个边框的样式,可以设置一到四个样式。
nonehidden dotted dashedsolid4161double groove ridge inset outsetborder-top简写属性。
将所有用于上边框的属性设置于一个声明中。
border-top-widthborder-styleborder-color4 1 6 1border-top-color设置上边框的颜色。
border-color 4 1 6 2 border-top-style设置上边框的样式。
border-style 4 1 6 2 border-top-width设置上边框的宽度。
thinmediumthicklength4 1 4 1border-width简写属性。
在一个声明中设置四个边框的宽度,可以设置一到四个值。
thinmediumthicklength4 1 4 1CSS 文本属性属性描述值IE F N W3C color设置文本颜色。
color 3 1 4 1 direction设置文本方向。
ltrrtl6 1 6 2letter-spacing设置字符间距。
normallength4 1 6 1text-align对齐元素中的文本。
leftrightcenterjustify4 1 4 1text-decoration向文本添加修饰。
noneunderlineoverlineline-throughblink4 1 4 1text-indent缩进元素中文本的首行。
length%4 1 4 1text-shadow nonecolorlengthtext-transform控制元素中的字母。
nonecapitalizeuppercaselowercase4 1 4 1unicode-bidi设置文本方向。
normalembed∙bidi-override5 2white-space设设置元素中空白的处理方式。
normalprenowrap5 1 4 1word-spacing设置字间距。
normallength6 1 6 1 CSS 字体属性(font)属性描述值IE F N W3Cfont简写属性。
作用是将所有针对字体的属性设置在一个声明中。
font-style font-variant font-weight∙font-size/line-heightfont-familycaptioniconmenumessage-boxsmall-captionstatus-bar4 1 4 1font-family字体类型名称或者针对某元素的类属族名名称的优先列表。
family-namegeneric-family3 14 1font-size设置字体的尺寸。
xx-smallx-smallsmallmediumlargex-largexx-large3 14 1smaller larger length%font-size-adjust为元素规定 aspect值。
none number---2font-stretch收缩或拉伸当前的字体族。
normal wider narrowerultra-condensed extra-condensed condensed semi-condensed semi-expanded expanded extra-expandedultra-expanded - - - 2font-style 设置字体样式。
normal italicoblique 4 1 4 1font-variant以小型小写字体或者正常字体显示文本normal small-caps 4 1 6 1font-weight 设置字体的粗细。
normal bold bolder lighter 100 200 300 400 500 600 700 8009004 1 4 1CSS 外边距属性 (margin)属性描述值IE F N W3Cpadding简写属性。
作用是在一个声明中设置元素的内边距属性。
padding-toppadding-rightpadding-bottompadding-left4 1 4 1padding-bottom设置元素的下内边距。
length%4 1 4 1padding-left设置元素的左内边距。
length%4 1 4 1padding-right设置元素的右内边距。
length%4 1 4 1padding-top设置元素的上内边距。
length%4 1 4 1 CSS 列表属性(list)属性描述值IE F N W3Clist-style简写属性。
用于将所有用于列表的属性设置于一个声明之中。
list-style-typelist-style-positionlist-style-image4 1 6 1list-style-image将图象设置为列表项标记。
noneurl4 1 6 1list-style-position设置列表中列表项标记inside 4 1 6 1内容生成轮廓属性描述值IEFNW3Coutline 简写属性。
用来在一个声明中设置所有的 outline 属性。
outline-color outline-style outline-width- 1.5 - 2outline-color 设置围绕元素的轮廓的颜色。
color invert- 1.5 - 2outline-style 设置围绕元素的轮廓的样式。
none dotteddashed solid double groove ridge inset outset- 1.5 - 2outline-width 设置围绕元素的轮廓的宽度。
thin medium thick length- 1.5 - 2CSS 尺寸属性 (Dimension)max-height设置元素的最大高度。
nonelength%- 1 6 2max-width设置元素的最大宽度。
nonelength%- 1 6 2min-height设置元素的最小高度。
length%- 1 6 2min-width设置元素的最小宽度。
length%- 1 6 2width设置元素的宽度。
auto%length4 1 4 1 CSS 分类属性(Classification)属性描述值IE F N W3Cclear设置不允许存在浮动对象的边leftrightbothnone4 1 4 1cursor规定光标类型(形状)urlautocrosshairdefaultpointermovee-resizene-resizenw-resizen-resizese-resizesw-resizes-resizew-resizetextwaithelp4 1 6 2display设置如何及是否显示某元素noneinlineblock4 1 4 1属性描述值IE F N W3Cbottom设置定位元素下外边距边界与其包含块下边界之间的偏移。
auto%length5 16 2clip设置元素的形状。
shapeauto4 1 6 2left设置定位元素左外边距边界与其包含块左边界之间的偏移。
auto%length4 1 4 2overflow设置当元素的内容溢visible 4 1 6 2出其区域时发生的事情。
hidden scrollauto position把元素放置到一个静态的、相对的、绝对的、或固定的位置中。