二.css
1.全局样式
/*==全局样式==*/
*{padding:0;margin:0;}
div,dl,dt,dd,form,h1,h2,h3,h4,h5,h6,img,ol,ul,li,table,th,td,p,span,a{border:0;}
img,input{border:none;vertical-align:middle;}
body{font-family:Tahoma,Arial,Helvetica,"宋体";font-size:12px;text-align:center;background:#FFF;color:#333;}
html{overflow-y:scroll;}
ul,ol{list-style-type:none;}
th,td,input{font-size:12px;}
h3{font-size:14px;}
button{border:none;cursor:pointer;font-size:12px;background-color:transparent;}
select{border-width:1px;_zoom:1;border-style:solid;padding-top:2px;font-size:12px;}
2. 普通样式
CSS样式分为:内联式css样式、嵌入式css样式、外部式css样式
①.内联式css样式表就是把css代码直接写在现有的HTML标签中:
<pstyle="color:#000099">我是一个内联式的样式</p>
嵌入式css样式
②.在HTML文档中的<head>中使用<style>标记,,被称为内嵌式。
<head>
<style>
/*选择符{属性:属性值;属性:属性值;}*/
a{color:#FF0000;}
#img1{width:800px;}/*id选择器*/
.img2{width:800px;}/*类选择器*/
</style>
③.外部式css样式(也可称为外联式)就是把css代码写一个单独的外部文件中,这个css样式文件以“.css”为扩展名(也可以为调用其他网站CSS)。
3.背景颜色
- background-color
例:
body { background-color: lightblue; }
4.背景图片
- background-image
5.字体颜色
color
<font color="#0000FF">
6.字体大小
font-size
7.浮动
float
8.居中
text-align:center
margin:0 auto
display:table-cell
垂直居中:行内元素的垂直居中把height和line-height的值设置成一样的即可
使用css3的translate水平垂直居中元素
9.外边距和内边距
margin 外边距
是指相邻同辈元素之间的距离。
相邻元素块的margin叠加显示
padding 内边距
定义元素边框与元素内容之间的距离。
10.宽和高
div {
width:200px; // 宽
height:200px; // 高
background:red;
}
11.字间距
text-indent设置抬头距离css缩进
letter-spacing来设置字与字间距_字符间距离,字体间距css样式
12.设圆角
border-radius (css3属性)
13.边框
border 边框
边框样式定义要显示怎样一个元素边界。