批改状态:合格
老师批语:
1.内部样式,仅对当前页面的元素生效,使用style标签
<style>h1{background-color:red;}</style>
2.外部样式,适用于所有引入了这个css样式表的html文档
<head><link rel="stylesheet" href="style.css"></head>
3.行内样式,仅适用于当前页面中指定的元素,使用style属性
<h1 style="color:teal">php中文网</h1>
实例:
<style>@import url(header.css);@import url(footer.css);</style>
1.将公共样式部分进行分离,并创建一些独立的样式表来保存它
2.使用@import指令将这些独立的公共样式表引入到指定的css文档或标签中
1.标签选择器
2.class选择器
3.id选择器
4.上下文选择器
5.结构伪类选择器
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>伪类选择器</title><style>/* 1.标签选择器,返回一组*//** li{background-color:violet;}*//* 2.类选择器:返回一组*/li.on{background-color: blue;}/* 3.id选择器:返回一个 */#foo{background-color: violet;}</style></head><body><ul><li id="foo">iteml1</li><li class="on">iteml2</li><li>iteml3</li><li class="on">iteml4</li><li class="on">iteml5</li></ul></body></html>
ul li{ background-color: lightblue;}body>ul>li{background-color: teal;}.start+li{background-color: lightgreen;}.start~li{background-color: lightgreen;}a 乘于 n 加 b
ul li:nth-of-type(2n+1){background-color:red;}2n-1 如下:2*0+1=12*1+1=32*2+1=5......具体某个标签ul li:nth-of-type(3){}选中第三个选择前三个ul li:nth-of-type(-n+3)选择偶数行ul li:nth-of-type(even){};选择奇数行ul li:nth-of-type(odd){};选择第一个ul li:first-of-type{};选择最后一个ul li:last-of-type{};选择最后三个ul li:nth-last-of-type(-n+3){};
总结:
nth-of-type 是正序选择
nth-last-of-type 是倒序选择
last-of-type 是最后一个
first-of-type 是第一个
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号