Blogger Information
Blog 38
fans 1
comment 0
visits 24324
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
4月26日作业CSS常用选择器
鲨鱼辣椒的博客
Original
647 people have browsed it

介绍关于css的一些常用选择器

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>常用选择器</title>
    <style>
        /*标签选择器*/
        ul {
            border: 1px solid red;
            margin: 0 auto;
            padding-left: 0;
        
        }
        
        /*层级选择器;子代选择器*/
        ul li{
            list-style: none;
            width: 40px;
            height: 40px;
            background-color: aqua;
            display: inline-block;
            text-align: center;
            line-height: 40px;
            border-radius: 50%;
            margin-left: 10px;
            /*设置阴影*/
            box-shadow: 2px 3px 1px #888;
        }
        
        /*id选择器*/
        #bg-blue{
            background-color: blue;
        }
        
        /*类选择器*/
        .bg-green{
            background-color: green;
        }
        
        /*属性选择器*/
        li[id='bg-blue']{
            border: 2px solid red;
        }
        
        /*群组选择器*/
        #bg-blue,.bg-green{
            border: 2px solid black;
        }
        
        /*相邻选择器*/
        #bg-blue + li{
            /*background-color: yellow;*/
        }
        
        /*兄弟同级选择器*/
        #bg-blue ~*{
            background-color: yellow;
        }
    </style>
</head>
<body>
<ul>
    <li>1</li>
    <li id="bg-blue">2</li>
    <li class="bg-green">3</li>
    <li class="bg-green">4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
</ul>
</body>
</html>

运行实例 »

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


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