基本选择器使用一

本文通过一个实例展示了如何使用CSS选择器来为不同元素应用样式。包括元素选择器、ID选择器、类选择器等,帮助读者理解并掌握CSS选择器的基本用法。
<!DOCTYPE html>
<html>
<head>
    <title>基本选择器使用</title>
    <style>
        *{margin:0;padding: 0}
        .clearfix:after,.clearfix:before{display:table;content:""}
        .clearfix:after{clear:both;overflow: hidden}
        .demo{width: 250px;border: 1px solid #cccccc; padding: 10px;margin: 20px auto;}
        li{list-style: none outside none; float: left;height:20px;line-height: 20px;width: 20px;border-radius: 10px;text-align: center;background: #36;color: green;margin-right: 5px;}
        .demo *{background: orange}
        /*--元素选择器*/
        ul{background: grey}
        /*--id选择器*/
        #first{background: lime;color: #000}
        #last{background: #000000;color: lime}
        /*类选择器*/
        .item{background: green;color:#fff;font-weight: bold}
        .item.important{background: red}
    </style>
</head>
<body>
    <ul class="clearfix demo">
        <li class="first" id="first">1</li>
        <li class="active">2</li>
        <li class="important item">3</li>
        <li class="important">4</li>
        <li class="item">5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li class="last" id="last">9</li>
    </ul>
</body>
</html>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值