Css first-of-type与last-of-type结构类

代码举例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>last-of-type</title>
    <style>
        div:last-of-type {
            color: red;
        }
    </style>
</head>
<body>
<div>1</div>
<p>2</p>
<div>3</div>
<section>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
</section>
<div>56666</div>
<p>11111</p>
</body>
</html>

由此可见 56666和5会变红

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>last-of-type</title>
    <style>
        div:first-of-type {
            color: red;
        }
    </style>
</head>
<body>
<div>1</div>
<p>2</p>
<div>3</div>
<section>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
</section>
<div>56666</div>
<p>11111</p>
</body>
</html>

由此可见 1和1会变红

人已赞赏
HTML+CSS

Css nth-of-type() 结构参数类

2019-9-22 16:22:59

HTML+CSS

only-child与only-of-type结构类

2019-9-22 16:35:44

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索