Blogger Information
Blog 21
fans 0
comment 0
visits 9292
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
伪类选择器+盒子模型属性
P粉116103988
Original
316 people have browsed it

伪类选择器

效果图如下:

代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>伪类选择器</title>
  8. </head>
  9. <style>
  10. div{
  11. font-size:1em;
  12. }
  13. /* 选中第二个li */
  14. .list >li:nth-of-type(2){
  15. color: red;
  16. }
  17. .list >ol>li{
  18. font-size:0.5em;
  19. color: blueviolet;
  20. }
  21. /* 选中后3个LI */
  22. .list > li:nth-last-of-type(-n+3){
  23. color: blue;
  24. }
  25. /* 奇数行 */
  26. .list >li:nth-of-type(2n-1){
  27. color:palevioletred;
  28. }
  29. input:disabled{
  30. color: red;
  31. border: none;
  32. }
  33. input:checked + label{
  34. color: blue;
  35. }
  36. button{
  37. border: none;
  38. background-color: green;
  39. font-size: 1em;
  40. color: aliceblue;
  41. padding: 5px;
  42. width: 60px;
  43. }
  44. button:hover{
  45. background-color: red;
  46. cursor: pointer;
  47. }
  48. </style>
  49. <body>
  50. <div class="text1">
  51. <ul class="list">
  52. <li class="first">item1</li>
  53. <li>item2</li>
  54. <li>item3</li>
  55. <ol>
  56. <li>zi1</li>
  57. <li>zi2</li>
  58. <li>zi3</li>
  59. </ol>
  60. <li>item4</li>
  61. <li>item5</li>
  62. <li>item6</li>
  63. <li>item7</li>
  64. <li>item8</li>
  65. </ul>
  66. </div>
  67. <div class="text2">
  68. <form action="">
  69. <legend>用户注册</legend>
  70. <div>
  71. <label for="user">姓名:</label>
  72. <input type="text" id="user" class="username" placeholder="请输入您的姓名">
  73. </div>
  74. <div>
  75. <label for="zy">注意:</label>
  76. <input type="text" id="zy" value="用户名必须实名" disabled>
  77. </div>
  78. <div>
  79. <label for="m">学历:</label>
  80. <select name="xl" id="">
  81. <option value="0" disabled >请选择</option>
  82. <option value="1">中学</option>
  83. <option value="2">大学</option>
  84. </select>
  85. </div>
  86. <div>
  87. <label for="m">性别:</label>
  88. <input type="radio" name="sex" id="m" value="0" checked />
  89. <label for="m"></label>
  90. <input type="radio" name="sex" id="wm" value="1" />
  91. <label for="wm"></label>
  92. </div>
  93. <button>提交</button>
  94. </form>
  95. </div>
  96. </body>
  97. </html>

盒子模型常用属性:

效果图如下:

代码如下:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>盒模型</title>
  8. <style>
  9. *{
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. /* 盒模型常用属性:padding,margin,border等 */
  15. .text1{
  16. width: 150px;
  17. height: 150px;
  18. background-color: pink;
  19. padding: 5px 10px 5px 8px;
  20. }
  21. .text2{
  22. background-color: rgb(158, 231, 158);
  23. border: 5px solid #000;
  24. border-radius: 5px;
  25. height: 100px;
  26. line-height: 100px;
  27. width: 100px;
  28. text-align: center;
  29. margin-top: 15px;
  30. margin-left: 15px;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="text1">
  36. <div class="text2">div</div>
  37. </div>
  38. </body>
  39. </html>
Correcting teacher:PHPzPHPz

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
Author's latest blog post