Blogger Information
Blog 70
fans 1
comment 0
visits 53096
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1216-选择器提权-字体图标-盒模型常用属性缩写
葡萄枝子
Original
559 people have browsed it

选择器提权-字体图标-盒模型常用属性缩写

作业内容:1. 实例演示选择器组合实现优先级提权方式; 2.实例演示字体与字体图标;3.实例演示盒模型常用属性的缩写方案

1. 实例演示选择器组合实现优先级提权方式

  1. <!DOCTYPE html>
  2. <html>
  3. <head>...</head>
  4. <body>
  5. <p class="paragraph on" id="foo">tag content</p>
  6. </body>
  7. </html>
  1. <style>
  2. /* 对元素 tag content 提权依次为 */
  3. /* [0, 0, 1] */
  4. p {
  5. background-color: violet;
  6. }
  7. /* 1. 声明顺序覆盖提权 */
  8. /* [0, 0, 1] */
  9. p {
  10. background-color: blueviolet;
  11. }
  12. /* 2. 元素组合提权 */
  13. /* [0 ,0 ,2] */
  14. body p {
  15. background-color: brown;
  16. }
  17. /* [0, 0, 3] */
  18. html body p {
  19. background-color: burlywood;
  20. }
  21. /* [0, 1, 0] */
  22. .paragraph {
  23. background-color: cadetblue;
  24. }
  25. /* [0, 1, 1] */
  26. p.paragraph {
  27. background-color: chartreuse;
  28. }
  29. /* [0, 1, 2] */
  30. body p.paragraph {
  31. background-color: chocolate;
  32. }
  33. /* [0, 1, 3] */
  34. html body p.paragraph {
  35. background-color: coral;
  36. }
  37. /* [0, 2, 0] */
  38. .paragraph.on {
  39. background-color: cornflowerblue;
  40. }
  41. /* [0, 2, 1] */
  42. p.paragraph.on {
  43. background-color: cornsilk;
  44. }
  45. /* [0, 2, 2] */
  46. body p.paragraph.on {
  47. background-color: crimson;
  48. }
  49. /* [0, 2, 3] */
  50. html body p.paragraph.on {
  51. background-color: cyan;
  52. }
  53. /* [0, 3, 0] */
  54. :root .paragraph.on {
  55. background-color: darkblue;
  56. }
  57. /* [0, 3, 1] */
  58. :root p.paragraph.on {
  59. background-color: darkcyan;
  60. }
  61. /* [0, 3, 2] */
  62. :root body p.paragraph.on {
  63. background-color: darkgoldenrod;
  64. }
  65. /* [1, 0, 0] */
  66. #foo {
  67. background-color: darkgray;
  68. }
  69. /* [1, 0, 1] */
  70. p#foo {
  71. background-color: darkgreen;
  72. }
  73. /* [1, 0, 2] */
  74. body p#foo {
  75. background-color: darkkhaki;
  76. }
  77. /* [1, 0, 3] */
  78. html body p#foo {
  79. background-color: darkmagenta;
  80. }
  81. /* [1, 1, 0] */
  82. .paragraph#foo {
  83. background-color: darkolivegreen;
  84. }
  85. /* [1, 1, 1] */
  86. p.paragraph#foo {
  87. background-color: darkorange;
  88. }
  89. /* [1, 1, 2] */
  90. body p.paragraph#foo {
  91. background-color: darkorchid;
  92. }
  93. /* [1, 1, 3] */
  94. html body p.paragraph#foo {
  95. background-color: darkred;
  96. }
  97. /* [1, 2, 0] */
  98. .paragraph.on#foo {
  99. background-color: darksalmon;
  100. }
  101. /* [1, 2, 1] */
  102. p.paragraph.on#foo {
  103. background-color: darkseagreen;
  104. }
  105. /* [1, 2, 2] */
  106. body p.paragraph.on#foo {
  107. background-color: darkslateblue;
  108. }
  109. /* [1, 2, 3] */
  110. html body p.paragraph.on#foo {
  111. background-color: darkslategray;
  112. }
  113. /* [1, 3, 0] */
  114. :root .paragraph.on#foo {
  115. background-color: darkturquoise;
  116. }
  117. /* [1, 3, 1] */
  118. :root p.paragraph.on#foo {
  119. background-color: darkviolet;
  120. }
  121. /* [1, 3, 2] */
  122. :root body p.paragraph.on#foo {
  123. background-color: deeppink;
  124. }
  125. </style>

2.实例演示字体与字体图标

  1. /* 已将 iconfont.* 复制到 css 目录 */
  2. <link rel="stylesheet" href="css/iconfont.css">
  1. <p>
  2. <span class="iconfont icon-baidu"></span>
  3. <span class="iconfont icon-google"></span>
  4. </p>

3.实例演示盒模型常用属性的缩写方案

  1. <!DOCTYPE html>
  2. <html>
  3. <head>...</head>
  4. <body>
  5. <div class="box">box conent</div>
  6. </body>
  7. </html>
  1. /* 盒模型常用属性的缩写 */
  2. .box{
  3. box-sizing: border-box;
  4. width: 300px;
  5. height: 200px;
  6. text-align: center;
  7. color: violet;
  8. /* 边框 border */
  9. border-width: 5px;
  10. border-color: red;
  11. border-style: solid;
  12. border: 15px red solid;
  13. /* 字体 font */
  14. font-family: 'Times New Roman', Times, serif;
  15. font-size: 36px;
  16. font-weight: lighter;
  17. font-style: italic;
  18. font: italic lighter 36px sans-serif;
  19. /* 背景 background */
  20. background-image: url(https://www.php.cn/static/images/user_avatar.jpg);
  21. background-repeat: no-repeat;
  22. background-position: top center;
  23. background: url(https://www.php.cn/static/images/user_avatar.jpg) no-repeat top center;
  24. /* 内外边距,上右下左 */
  25. padding: 10px 20px;
  26. margin: 15px;
  27. background-color: grey;
  28. background-clip: content-box;
  29. }
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