CSS简单笔记
系列链接
HTML简单笔记
CSS简单笔记
JavaScript简单笔记
jQuery简单笔记
拓展简单笔记
一 基本语法
-
<html> <head> <style type="text/css"> 选择器名{ 样式属性:样式数值; 样式属性:样式数值; 样式属性:样式数值; } </style> </head> </html> <!--code0--> - ```css .类名{ 样式属性:样式数值; 样式属性:样式数值; 样式属性:样式数值; } <!--code1--> - 标签里写`id="ID"` -
引用方式
-
<!-- 内部样式 --> <head> <style type="text/css"> 选择器名{ 样式属性:样式数值; 样式属性:样式数值; 样式属性:样式数值; } </style> </head><!-- 只能当前页面使用 --> <!--code2--> -
<!-- 行内样式 --> <span style="font-size:25px;color:pink;">爱</span> <!--code3-->
-
后代选择器
1
2
3
4
5
6
7
8
9<!-- 层次关系 --><!-- 还可以和交集选择器用 -->
选择器1 选择器2{
}
列子:
p .red{
color:red
}
<p>我<span class="red">爱</span>你</p> -
并集选择器
-
选择器1,选择器2,选择器3{ } <!--code5--> -
伪类名称 含义 示例 a:link未单击访问时超链接样式 a:link{color:#9ef5f9;}a:visited单击访问后超链接样式 a:visited{color:#333;}a:hover鼠标悬浮其上的超链接样式 a:hover{color:#ff7300;}a:active鼠标单击未释放的超链接样式 a:active{color:#999;} -
设置伪类的顺序:
a:link->a:visited->a:hover->a:active -
一般和超链接标签配合使用
-
-
背景样式
background-colorbackground-image:url(路径)background-repeat:图片平铺方式no-repeatrepeat-xrepeat-y默认:repeatbackground-position:设置图片偏远50px 100px50% 100%left bottomcenter centerright top等等background:颜色 图片 position repeat
-
列表样式
-
list-style-type值 说明 语法示例 none无标记符号(可做导航栏; 可横排 间隔) list-style-type:none;disc实心圆,默认类型 list-style-type:disc;circle空心圆 list-style-type:circle;square实心正方形 list-style-type:square;decimal数字 list-style-type:decimal; -
list-style-image1
2
3
4li{
list-style-image: url(image/arrow-right. gif);
list-style-type: circle;
} -
list-style-position:insideoutside
-
五 结合<div>
-
用法 :
- 网页布局
- 排版网页内容
-
语法例子:
1
2
3
4
5
6#header {
width:200px;
height:280px;
}
<div id="header"> 网页内容 </div> -
可加属性
border:1px red solid;