關於css偽類別選取器

來源:互聯網
上載者:User

標籤:

  常見的偽類(pseudo-classes)和虛擬元素(pseudo-elements)

偽類::hover 滑鼠放上去的效果

:actiive  點擊之後效果

 

虛擬元素

:before  

:after

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Document</title>    <style type="text/css">        *{            margin: 0;            padding: 0;        }        ul{            width:1000px;            margin: 0 auto;            counter-reset:li;        }        li{            list-style: none;        }        ul>li{            background-color: #ccc;            margin-top: 10px;        }        ul>li:before{            content: counter(li);            counter-increment:li;            background-color: #333;            border-radius:100%;            padding: 0 5px;            color: #fff;            margin-right: 10px;        }        .test{            width: 200px;            height: 200px;            background: #000;            color: #fff;        }        .test:before{            content: " ";            color: red;            width: 20px;            height: 20px;            background: #fff;            float: left;        }        .test:after{            content:" ";            color: green;            width: 20px;            height: 20px;            background: #fff;            float: right;        }    </style></head><body><div class="test">    hhhkjkkj</div><ul>    <li>List item one</li>    <li>The second item on the list</li>    <li>Number three is a bit longer, with some lorem ipsum for good measure. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</li>    <li>And here is number four.</li>    <li>The fifth item on the list</li>    <li>The sixth item on the list</li></ul></body></html>

清浮動:

.clearfix{zoom:1;}     .clearfix:after {clear:both;content:‘.‘;display:block;width: 0;height: 0;visibility:hidden;}

 

關於css偽類別選取器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.