博客列表 >简单选择器

简单选择器

霏梦
霏梦原创
2020年06月16日 07:34:29608浏览

- 作者:霏梦

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>选择器,简单选择器</title>
  7. <style>
  8. /* 元素选择器,也就是标签选择器 --> */
  9. body {
  10. background-color: lightcyan;
  11. }
  12. /* 类选择器对应者hmtl标签中的class属性 */
  13. .wsp {
  14. border: 1px solid rgb(10, 10, 10);
  15. }
  16. /* 多个类复合应用 */
  17. .wsp.center {
  18. background-color: yellow;
  19. }
  20. /* id选择器 */
  21. #first {
  22. background-color: lightpink;
  23. }
  24. /* id,class可以添加到任何元素上,所以可以省略 */
  25. /* *属于元素级别, 元素<class<id */
  26. /* #first.wsp { */
  27. /* background-color: red; */
  28. /* } */
  29. /* id选择器的应用场景只有二个场景,表单元素,锚点里 */
  30. </style>
  31. </head>
  32. <body>
  33. <h3 class="h3-title">我是标题</h3>
  34. <p class="wsp" id="first">我是第1行</p>
  35. <p class="wsp">我是第2行</p>
  36. <p class="wsp">我是第3行</p>
  37. <p class="wsp">我是第4行</p>
  38. <p class="wsp center">我是第5行</p>
  39. <p class="wsp">我是第6行</p>
  40. <p class="wsp">我是第7行</p>
  41. <p class="wsp">我是第8行</p>
  42. <p class="wsp">我是第9行</p>
  43. </body>
  44. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议