博主信息
博文 15
粉丝 0
评论 0
访问量 16394
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
常用的两种伪类选择器
P粉932932019
原创
861人浏览过

一、结构伪类选择器

  1. <style>
  2. .catelist{
  3. margin: 20px;
  4. }
  5. /* 结构伪类选择器 */
  6. .item:nth-of-type(2){
  7. color: red;
  8. }
  9. .item:nth-of-type(2n){
  10. background-color: rgb(227, 227, 227);
  11. }
  12. .item:nth-last-of-type(1){
  13. color: blue;
  14. }
  15. .item:nth-last-of-type(3){
  16. color: rgb(15, 241, 15);
  17. }
  18. </style>
  19. <ol class="catelist">
  20. <li class="item">item1</li>
  21. <li class="item">item2</li>
  22. <li class="item">item3</li>
  23. <li class="item">item4</li>
  24. <li class="item">item5</li>
  25. <li class="item">item6</li>
  26. <li class="item">item7</li>
  27. <li class="item">item8</li>
  28. </ol>

二、状态伪类选择器

  1. <style>
  2. /* 状态伪类选择器 */
  3. input:focus{
  4. background-color: aquamarine;
  5. border: 1px dashed gray;
  6. }
  7. input:disabled{
  8. color: red;
  9. border: none;
  10. }
  11. button{
  12. width: 150px;
  13. height: 30px;
  14. border: none;
  15. margin-bottom: 10px;
  16. background-color: greenyellow;
  17. }
  18. button:hover{
  19. background-color: red;
  20. cursor: pointer;
  21. color: #fff;;
  22. }
  23. </style>
  24. <div class="regist">
  25. <form action="check.php" method="post">
  26. <fieldset>
  27. <legend>用户注册</legend>
  28. <label>用户名:<input type="text" /></label>
  29. <label>
  30. 性别:<input type="radio" name="sex" value="1" checked />
  31. <input type="radio" name="sex" value="0" />
  32. </label>
  33. <label>
  34. 警告:<input type="text" value="一旦注册不可修改" disabled />
  35. </label>
  36. <button>提 交</button>
  37. </fieldset>
  38. </form>
  39. </div>

批改老师:PHPzPHPz

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系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+教程免费学