您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
一、元素选择器
1.最常见的选择器就是元素选择器,文档的元素就是最基本的选择器
例如:h2{} a{} ……
<p>HelloWorld</p>
p{
color: blue;
}二、选择器分组
1.例子:
h2、h3{}
h2,h3{
color: red;
} 2.通配符:
*{}
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>选择器</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <h2>标题1</h2> <h3>标题2</h3> <p>HelloWorld</p> </body> </html>
*{
color: red;
}
h2,h3{
font-size: 45px;
} 通常会使用通配符来取消内外边距
*{
margin: 0px;
padding: 0px;
}三、类选择器
1.类选择器允许以一种独立于文档元素的方式来指定样式
例如:.class{}
.div{
color: red;
} 2.结合元素选择器
例如:a.class{}
a.div{
color: red;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="div">
HelloWorld
</div>
<a class="div">HelloWorld</a>
</body>
</html> 3.多类选择器
例如:.class.class{}
.p1{
color: blue;
}
.p2{
font-size: 30px;
}
.p1.p2{
font-style: italic;
}<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>选择器</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <p class="p1">This is my web page</p> <p class="p2">This is my web page</p> <p class="p1 p2">This is my web page</p> </body> </html>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。