CSS基础例子

参考:http://www.w3school.com.cn/example/csse_examples.asp
一.背景
background: #00ff00 url(/i/eg_background3.jpg) no-repeat fixed center;
background: #00ff00 
background: url(/i/eg_background3.jpg)
二、在一个声明中定义所有的列表属性
ul{list-style: url('/i/eg_arrow.gif') inside }   ul{list-style: url('/i/eg_arrow.gif') outside }
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Coca Cola</li>
</ul>
三、CSS 外边距 (margin)
.tesclass{margin: 2cm 4cm 3cm 4cm}  .tesclass{margin: 2cm 4cm } 
.tesclass{margin: 2cm }  
.tesclass{margin: 2cm 4cm 3cm }  遵循上右下左逆时针
四、CSS 内边距 (padding)
同 margin,
五.CSS 边框(border)
 border: 2px solid #f00 
border-bottom:2px solid #f00  三个参数分别为 宽度,实线,颜色
六、设置文本颜色 h1 {color: #00ff00}
七、 CSS 定位 position:
绝对定位(相对其父元素):position:absolute;
left:100px;
top:300px
相对定位(相对其正常位置):position:relative;
left:100px;
top:100px;
z-index:-1 位于下面 1位于上面 正常为0
八、链接伪类
:link 将特殊的样式添加到未被访问过的链接
:hover 当鼠标悬浮在元素上方时,向元素添加样式
:active 将样式添加到被激活的元素,即鼠标按下不放时的样式
:visited 将特殊的样式添加到被访问过的链接
a:link {color: green}
a:visited {color: red}
a:hover {color: yellow}
a:active {color: blue}

原文地址:https://www.cnblogs.com/ganmk/p/1201711.html