选择器
/* */注释
<link rel="stylesheet" href="path">
p {}元素选择器
#idname {}id选择器, 搭配id="idname"
.classname {},p.classname {}类选择器, 搭配class="classname"
* {}通用选择器
li a{},.cls p{}后代选择器
p[属性1][属性2="xxx"]含有属性1,且属性2="xxx"
a,p相同设置不重写
伪类选择器
a:link {color: #FF0000} /* 未访问的链接 */
a:visited {color: #00FF00} /* 已访问的链接 */
a:hover {color: #FF00FF} /* 鼠标移动到链接上 */
a:active {color: #0000FF} /* 选定的链接 */
input:focus { outline: none; background-color: #eee;} /*输入框进入输入状态
继承
css属性继承。除了border, margin, padding, background
属性
文字
font-family字体
font-size=px
font-weight=100~900字体粗细
color = #FF0000,color=rgba(255,0,0,0.3)后者最后一个参数在0-1之间定义不透明度,0是透明
text-align=left,center,right对齐
text-decoration=none,underline,overline,line-through文字修饰
网页
width=px
height=px
background:color url('..') no-repeat fixed;对应-color,-image,-repeat,-attachment. 其中fixed是固定图片不随网页滚动
边界
content->padding->border->margin
border: 2px solid red对应-width,-style,-color. 其中style由none无,solid实线,dashed线状虚线,dotted点状虚线
还可以设置border-top,border-right, border-bottom,border-left这样
margin: 5px 10px 15px 20px;顺序上右下左
padding: 5px 10px 15px 20px;顺序上右下左