CSS
# 层叠样式表
# 给网页骨架添砖加瓦
语法结构:
选择器 {
属性名:属性值
}
注释:
/*
这是注释
*/
ctrl + ? (快捷键)
1. 基本选择器
2. 属性选择器
3. 伪类选择器
4. 伪元素选择器
5. 后代选择器
6. 并列选择器
设置长宽:
'''
默认只有块儿级元素可以设置长宽
默认行内元素不能设置长宽
'''
文字属性:
font-size
font-weight
颜色属性
color:red
选择器
后代选择器
#d1 .p1 .s1 {
color: red;
}
并列选择器
#d1 .p1 .s1 , #d2 a , .s2 {
color: red;
}
颜色属性
#d1 .p1 .s1 {
/*color: red;*/
/*1600w 种颜色*/
/*color: #5b9648; */
/*0-255*/
/*color: rgb(43, 43, 44);*/
color: rgba(255, 0, 0, 0.1);
}
背景属性
/*background-color: red;*/
/*background-image: url("123.png");*/
/*background-repeat: repeat-x;*/
/*background-repeat: repeat-y;*/
/*background-repeat: no-repeat;*/
/*background-position: center center;*/
/*background-position: 100px 50px;*/
/*只要是前缀一样的属性,都可以简写 */
background: no-repeat center center red url("123.png") ;
边框属性
border-left-color: red;
border-left-style: solid;
border-left-width: 5px;
border-top-color: green;
border-top-style: dashed;
border-top-width: 5px;
border-right-color: blue;
border-right-style: solid;
border-right-width: 2px;
border-bottom-color: blueviolet;
border-bottom-style: solid;
border-bottom-width: 5px;
border: 5px solid red;
# border-radius: 50% 画圆
display属性
# inline: 行内元素
# block:块儿级元素
# inline-block:既有行内元素又有块儿级元素的特征
# none:隐藏
盒子模型
# margin:外边距
以两个快递盒子为例,快递盒与快递盒之间的距离我们称为外边距
# padding: 内边距
物品与盒子之间的距离,我们称之为内边距
# border
# content
'''
面试题:margin值是否叠加?
不叠加,按照最大的显示
'''
浮动
# float:left
# float:right
#d2{
height: 100px;
width: 100px;
background-color: yellow;
float: left;
}
#d3{
height: 100px;
width: 100px;
background-color: blue;
float: left;
}
.clearfix:after {
content: '';
display: block;
clear: both;
}