首页 > 其他 > 详细

选择器

时间:2019-05-21 16:33:51      阅读:125      评论:0      收藏:0      [点我收藏+]

cssx选择器

技术分享图片

技术分享图片
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="css/hello.css" type="text/css" rel="stylesheet" />
        
    </head>
    <body>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
    </body>
</html>
View Code

 id选择器

技术分享图片
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="css/hello.css" type="text/css" rel="stylesheet" />s
    </head>
    <body>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span><br/>
        <span id="style2">这是一则非常重要的新闻</span><br/>
        
    </body>
</html>
View Code

html选择器 

技术分享图片
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="css/hello.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        你好北京!
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span><br/>
        <span id="style2">这是一则非常重要的新闻</span><br/>
        
    </body>
</html>
View Code

hello.css

技术分享图片
.hello{
    font-weight: bold;
    font-size: 20px;
    background: pink;
}

#style2{
    font-weight: 30px;
    background: gold;
}
body{
    color: purple;
}
View Code

当一个元素被id选择器与类选择器html选择器修饰

优先级是:id>类>html

 

综合案例;

技术分享图片
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="css/hello.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        你好北京!
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span>
        <span class="hello">新闻一</span><br/>
        <span id="style2">这是一则非常重要的新闻</span><br/>
        <a href="h1.html">goto souhu</a><br/>
        <a href="h3.html">goto souhu</a><br/>
        <a href="h2.html">goto souhu</a><br/>
    </body>
</html>
View Code
技术分享图片
.hello{
    font-weight: bold;
    font-size: 20px;
    background: pink;
}

#style2{
    font-weight: 30px;
    background: gold;
}
body{
    color: purple;
}
a:link{
    color: black;
    text-decoration: none;
}
a:hover{
    text-decoration: underline;
    color: black;
}
a:visited{
    color: red;
}
View Code

 

选择器

原文:https://www.cnblogs.com/helloworld2019/p/10900304.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!