目录css
能够将任意多个选择器分组到一块儿,并用逗号分隔。html
div,.s,section{ color:red; }
若是只但愿影响到某个标签下的第一级标签,能够用子代选择器。布局
x > y。只会影响到x标签下的y标签,不会影响到x标签下的z标签里的y标签。spa
div>strong{ color:red; }
又称包含选择器。只要是在这个标签里的某种标签都会被影响code
x 空格 y。x标签下全部的y标签htm
div a { text-decoration: none; }
若是须要选择紧接在另外一个元素后的元素,并且两者有相同的父元素,可使用相邻兄弟选择器。索引
x + y。x标签左右的y标签图片
span+section{ background-color:pink; }
x ~ y。x标签附近的全部的y标签。兄弟选择器包括相邻选择器。文档
span~section{ background-color:brown; }
相交的部分就是要设置属性值的标签get
xy。即有x又有y
i.s{ color: yellow; } <i class='s'>iiii</i>
同目录结构下
子代与后代优先级相投。相邻与兄弟优先级相同。
最终的样式采用逻辑后的样式根据选择器权值进行比较
不一样目录结构下
根据选择器权值进行比较
权值为标签权重之和
权重: *:1
div:10
class:100
id:1000
!important:10000
权值比较时,关心的是值的大小,不关心位置和具体选择器名
权值相同时,靠位置决定
id永远比class大,class永远比标签大
控制的是同一目标才具备可比性
属性选择器权重与class选择器同样
有属性class的全部标签
[class]{ color: orange; }
有属性class且值为d2的全部标签
[class='d2']{ color: pink; }
div且class='d2',权重增长
div[class='d2']{ color: blue; }
属性以什么开头:^=
[class^='he']{ color: yellow; }
属性以什么结尾:$=
[class^='rd']{ color: tan; }
属性模糊匹配:*=
[class^='llo']{ color: cyan; }
风格 | 解释 |
---|---|
solid | 实线 |
dashed | 虚线 |
dotted | 点状线 |
double | 双实线 |
groove | 槽状线 |
ridge | 脊线 |
inset | 内嵌效果线 |
outset | 外凸效果线 |
值得个数 | 方位 |
---|---|
1 | 上下左右 |
2 | 上下 | 左右 |
3 | 上 | 左右 | 下 |
4 | 上 | 右 | 下 | 左 |
赋值个数 | 方位 |
---|---|
1 | 上下左右 |
2 | 上下 | 左右 |
3 | 上 | 左右 | 下 |
4 | 上 | 右 | 下 | 左 |
border-top-left-radius
一个固定值:表示横纵 border-top-left-radius: 100px; 两个固定值:表示横与纵 border-top-left-radius: 100px,50px; 百分比赋值 border-top-left-radius: 100%;
border-radius
不分方位 左上为第一个角,顺时针,不足找对角 border-radius: 30px; 区分横纵 1.控制横向/控制纵向 2.横向又能够分为1,2,3,4个值;纵向亦然 border-radius: 10px 100px 50px /50px; 左上横10 右上横100 右下横50 左下横100/纵向全为50
<a href="连接地址" title='鼠标悬浮的文本提示' target='目标位置'></a>
target:_self 当前页面打开 | _blank 新开空白标签为来打开目标网页
<a href="https://www.baidu.com">百度</a>
注:若是是在本地的连接。当前目录./ 上一级目录..
a { color: #333; text-decoration: none; outline: 0 }
经过锚点名与#锚点名建起关联
name='tag'|href='#tag'
前往底部
<a href="#tag">前往底部</a>
设置一个锚点
<div class="bottom"> <a name="tag">底部</a> </div>
<img src="图片地址" alt="加载错误提示文字" title="鼠标悬浮的文本提示">
<style> ol,ul{ margin: 0; padding:0; list-style: none; } </style>
<ol> <li>列表项</li> <li>列表项</li> <li>列表项</li> </ol>
<ul> <li>列表项</li> <li>列表项</li> <li>列表项</li> </ul>
注:鼠标样式
{ cursor: pointer | wait | move; }
.txt:before{ content: '我是前缀```' } .txt:after{ content: '```我是后缀' }
注:位置从1开始
*{ margin: 0 }
布局方位:margin-left、margin-right、margin-top、margin-bottom
影响自身布局:margin-left、margin-top
影响兄弟布局:margin-right、margin-bottom
margin-bottom影响上下兄弟,尽可能别对margin-right进行设置
margin-right影响上下兄弟,尽可能别对margin-bottom进行设置
<!-- 坑1 --> <section class="s1"></section> <section class="s2"></section>
盒模型布局的坑只出如今和margin-top相关的地方
.s1,.s2{ width: 100px; height: 100px; background-color: pink; }
和左右不同,上下top会重叠取大值
.s1{ margin-bottom: 20px; } .s2{ margin-top: 20px; }
<!-- 坑2 --> <div class="sup"> <div class="sub"></div> </div>
.sup{ width: 200px; height: 200px; background-color:cyan; } .sub{ width: 100px; height: 100px; background-color:orange; }
父子top重叠,取大值
.sup{ margin-top: 50px; } .sub{ margin-left: 50px; /*margin-top:100px;*/ }
1.将父级固定
.sup{ /border-top: 1px solid black;/ /border-top: 1px solid transparent;/ /保证显示区域不变200200/ /height: 199px/ }
2.经过padding
.sup{ padding-top:50px; height: 150px; }