批改状态:合格
老师批语:
根据元素的位置或状态来匹配子元素
与上下文选择器很相似
:nth-child():在括号内定义:first-child:第一个元素:last-child:最后一个:nth-last-child():倒数获取第一个元素:
.list>.item:nth-child(1){background-color: violet;}/* 括号内填写多少数字就获取对应的元素 */
获取最后一个元素:
.list > .item:first-child {background-color: violet-;}
获取倒数第三个元素:
.list > .item:last-child {background-color: violet-;}
.list>.item:nth-last-child(3){background-color: violet;}
链接,表单
:hover: 鼠标悬停:enabled: 有效控件:disabled: 禁用控件:checked: 选中控件:required: 必选控件:focus: 焦点控件:not(): 过滤掉某些元素:empty(): 空更多查询 MDN
可简单理解为: 标签是个位, class 是十位, id 是百位
<html>,{outline:1px solid red}width: 宽height: 高padding: 内边距border: 边框margin: 外边距width,style,colorwidthpadding/marginpadding,borderbox-sizing: 设置盒模型计算边界content-box: 默认值,仅包括内容区border-box: 推荐值,宽高扩展到可视边框```css
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号