Blogger Information
Blog 32
fans 0
comment 0
visits 23503
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS常用选择器-2019年4月25日9点00分
小李广花荣
Original
980 people have browsed it
  1. 下面代码将会用到常用的选择器类型

实例

ul li{
    list-style: none;
    display: inline-block;
}
.a1{
    color: red;
}
#a2{
    color: #00CC66;
}
li{
    color: #0000FF;
}
ul :first-child{
    color: wheat;
}
ul :last-child{
    color: #0F0F0F;
}
ul :nth-child(1){
    color: #0E774A;
}

div :nth-of-type(2){
    color: #0000FF;
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS中常用选择器</title>
    <link rel="stylesheet" href="style/style.css">
</head>
<body>
<ul>
    <li class="a1">你好</li>
    <li id="a2">你好</li>
    <li>你好</li>
</ul>
<div>
    <p>HTML</p>
    <p>CSS</p>
    <p>Jquery</p>
</div>
<div>
    <p>JAVA</p>
    <p>c#</p>
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

QQ图片20190427144801.png

上面运行后的结果视图,运用了常用类选择器

2.这次学习到了几种选择器常用的用法比如

 class   .

 id      #

标签   以及 伪类选择器  :first-child  :list-first  :nth-of-type() :nth-child()

等常用的选择器 div : 中间要加一个空格 页面才会起效果

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!