博主信息
博文 56
粉丝 0
评论 4
访问量 48429
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
CSS: 伪类和参数-复习
异乡客
原创
873人浏览过

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>选择器:伪类</title>
</head>
<body>
<!-- 伪类: 1.结构伪类:根据元素位置获取元素 2.状态伪类:根据状态来获取元素 -->

  1. <ul class="list">
  2. <li class="first">item1</li>
  3. <li>item2</li>
  4. <li>item3</li>
  5. <li>item4</li>
  6. <li>item5</li>
  7. <li>item6</li>
  8. <li>item7</li>
  9. <li>item8</li>
  10. <p>aaaa</p>
  11. <p>bbbb</p>
  12. <p>cccc</p>
  13. </ul>
  14. <style>
  15. /* .list >:first-child{
  16. background-color: red;
  17. } */
  18. /* .list >p:first-of-type{
  19. background-color: yellow;
  20. }
  21. .list .first{
  22. background-color: lightgreen;
  23. } */
  24. /* .list >li:nth-of-type(3){
  25. background-color: lightblue;
  26. } */
  27. /* .list >li:nth-last-of-type(3){
  28. background-color: lightblue;
  29. } */
  30. .list >p:nth-of-type(2){
  31. background-color: lightblue;
  32. }
  33. .list :first-of-type{
  34. background-color: lightblue;
  35. }
  36. </style>
  37. </body>
  38. </html>
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学