Blogger Information
Blog 40
fans 0
comment 1
visits 24383
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第5章 1215-css引入方式与选择器,学习心得、笔记
努力工作--周工--Robin
Original
463 people have browsed it

今天所学心得、笔记

1、css规则的三种引入到html文档中的方式

  1. <!-- 1、CSS样式引入:内联方式-->
  2. <div class="d1" style="width: 100px; height: 100px; background-color: violet"></div>
  3. /*2、CSS样式引入:内部方式*/
  4. .d2 {
  5. width: 100px;
  6. height: 100px;
  7. background-color: violet;
  8. }
  9. <!--3、CSS样式引入:外部方式-->
  10. <link rel="stylesheet" href="../css/style.css">

2、标签选择器

  1. /*id选择器*/
  2. #test {
  3. background-color: violet;
  4. }
  5. /*类选择器*/
  6. .list {
  7. background-color: lightblue;
  8. }
  9. /*并集选择器*/
  10. #test, .list {
  11. background-color: red;
  12. }
  13. /*后代选择器*/
  14. ul li {
  15. background-color: lightcoral;
  16. }
  17. /*子代选择器*/
  18. ul>li {
  19. background-color: lightcyan;
  20. }
  21. /*后面紧相邻一个元素选择*/
  22. #test + li {
  23. background-color: lightblue;
  24. }
  25. 后面所有元素选择
  26. .list ~ li {
  27. background-color: lightblue;
  28. }
  29. /*选择第一个*/
  30. ul li:first-of-type {
  31. background-color: red;
  32. }
  33. /*选择最后一个*/
  34. ul li:last-of-type {
  35. background-color: red;
  36. }
  37. /*选择第三个*/
  38. ul li:nth-of-type(3) {
  39. background-color: violet;
  40. }
  41. /*选择倒数第三个*/
  42. ul li:nth-last-of-type(3) {
  43. background-color: violet;
  44. }
  45. /*偶数选择器*/
  46. ul li:nth-of-type(even) {
  47. background-color: lightcyan;
  48. }
  49. /*奇数选择器*/
  50. ul li:nth-of-type(odd) {
  51. background-color: lightcoral;
  52. }
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments