找回密码
 立即注册

day2-1,css结构伪类选择器-基本使用

[复制链接]
admin 发表于 2025-5-18 09:21:41 | 显示全部楼层 |阅读模式
  1. <style>
  2.     /* 第一个 */
  3.     /* li:first-child {
  4.       background-color: green;
  5.     } */

  6.     /* 最后一个 */
  7.     /* li:last-child {
  8.       background-color: green;
  9.     } */

  10.     /* 任意个 */
  11.     /* li:nth-child(3) {
  12.       background-color: green;
  13.     } */

  14.     li:nth-child(1) {
  15.       background-color: green;
  16.     }
  17.   </style>
复制代码

1.jpg

2.jpg

 楼主| admin 发表于 2025-5-18 09:22:57 | 显示全部楼层
<style>
    /* 偶数 */
    /* li:nth-child(2n) {
      background-color: green;
    } */

    /* 奇数 */
    /* li:nth-child(2n+1) {
      background-color: green;
    } */

    /* 倍数 */
    /* li:nth-child(5n) {
      background-color: green;
    } */

    /* n 从0开始 */
    /* 第5个以后的标签 */
    /* li:nth-child(n+5) {
      background-color: green;
    } */

    /* 第5个以前的标签 */
    li:nth-child(-n+5) {
      background-color: green;
    }
  </style>

QQ|网站地图|Archiver|手机版|金黑网络 ( 粤ICP备2021124338号 )

网站建设,微信公众号小程序制作,商城系统开发,高端系统定制,app软件开发,智能物联网开发,直播带货系统等

Powered by Www.Jinhei.Cn

Copyright © 2013-2024 深圳市金黑网络技术有限公司 版权所有

快速回复 返回顶部 返回列表