Blogger Information
Blog 30
fans 0
comment 1
visits 24015
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
12月23,关于FLEX弹性盒子的初识及基本的运用方式
Original
833 people have browsed it

12月20日作业用才学的FLEX弹性盒子,重新写了一次

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <link rel="stylesheet" href="font/iconfont.css">
  6. <title>Title</title>
  7. <style>
  8. *{
  9. margin: 0;
  10. padding: 0;
  11. font-size: 14px;
  12. }
  13. img{
  14. display: block;
  15. }
  16. a{
  17. margin-right: 10px;
  18. text-decoration: none;
  19. color: black;
  20. }
  21. /*A标签鼠标事件*/
  22. a:hover{
  23. color: red;
  24. }
  25. /*父级元素变为弹性盒子*/
  26. .box{
  27. margin: auto;
  28. width: 1300px;
  29. flex-direction: row;
  30. display: flex;
  31. flex-wrap: wrap;
  32. }
  33. div:not(.box){
  34. margin-top: 10px;
  35. }
  36. /*设置LOGO 搜索框 以及快速入口的大小,以方便换行*/
  37. .box > div:nth-child(-n+3){
  38. width: 400px;
  39. /*line-height: 76px;*/
  40. align-items: center;
  41. }
  42. /*设置了快速入口内容的对齐方式*/
  43. .box>div:nth-child(3){
  44. text-align: right;
  45. }
  46. /*把.box里面的最后一个item项目设置为弹性盒子,以方便图片排版*/
  47. .box>div:nth-last-child(1){
  48. display: flex;
  49. }
  50. .box>div:nth-last-child(1) img:nth-child(2){
  51. margin-left: 2px;
  52. }
  53. /*引入字库设置*/
  54. .icon-huiyuan1 {
  55. margin-left: 10px;
  56. margin-right: 10px;
  57. }
  58. .icon-sousuo2 {
  59. font-size: 20px;
  60. }
  61. .icon-huiyuan1{
  62. font-size: 35px;
  63. }
  64. .icon-DOC{
  65. font-size: 40px;
  66. color: red;
  67. }
  68. /*搜索框设置*/
  69. input,button{
  70. margin-right: 20px;
  71. }
  72. input{
  73. height: 30px;
  74. width: 300px;
  75. border: 1px solid ;
  76. border-radius: 10px;
  77. outline: none;
  78. }
  79. button{
  80. border: 0;
  81. background-color: transparent;
  82. padding: 0;
  83. margin-left: -45px;
  84. }
  85. /*把父级元素下的第四个DIV项目设置为弹性盒子,方便管理里面的内容*/
  86. .box-4{
  87. display: flex;
  88. flex-direction: row;
  89. flex-wrap: wrap;
  90. width: inherit;
  91. }
  92. /*父级元素下第四个DIV项目的具体设置*/
  93. .box-4 > span:nth-child(2){
  94. width: 30px;
  95. border-right: 1px solid lightgray;
  96. }
  97. .box-4 > span:nth-child(3){
  98. margin-left: 10px;
  99. width: 180px;
  100. }
  101. .box-4 > span:nth-child(5){
  102. width: 30px;
  103. border-right: 1px solid lightgray;
  104. }
  105. .box-4 > span:nth-child(6){
  106. margin-left: 10px;
  107. width: 180px;
  108. }
  109. .box-4 > span:nth-child(8){
  110. width: 30px;
  111. border-right: 1px solid lightgray;
  112. }
  113. .box-4 > span:nth-child(9){
  114. margin-left: 10px;
  115. width: 180px;
  116. }
  117. .box-4 > span:nth-child(11){
  118. width: 30px;
  119. border-right: 1px solid lightgray;
  120. }
  121. .box-4 > span:nth-child(12){
  122. margin-left: 10px;
  123. width: 180px;
  124. }
  125. </style>
  126. </head>
  127. <body>
  128. <div class="box">
  129. <div>
  130. <img src="../预习资料/flex弹性布局复习资料/flex/简介/demo/logo.png" alt="">
  131. </div>
  132. <div style="text-align: right;"><input type="search"><button class="iconfont icon-sousuo2"></button></div>
  133. <div>
  134. <a href="" class="iconfont icon-huiyuan1"></a>
  135. <a href="" class="iconfont icon-huiyuan1"></a>
  136. <a href="" class="iconfont icon-huiyuan1"></a>
  137. <a href="" class="iconfont icon-huiyuan1"></a>
  138. <a href="" class="iconfont icon-huiyuan1"></a>
  139. <a href="" class="iconfont icon-huiyuan1"></a>
  140. </div>
  141. <div class="box-4">
  142. <span class="iconfont icon-DOC"></span>
  143. <span>咨询学习</span>
  144. <span>
  145. <span><a href="">器材</a></span>
  146. <span><a href="">大师</a></span>
  147. <span><a href="">学员</a></span>
  148. <span><a href="">实战</a></span>
  149. <span><a href="">大赛</a></span>
  150. <span><a href="">裤子</a></span>
  151. <span><a href="">影视</a></span>
  152. <span><a href="">其他</a></span>
  153. </span>
  154. <span class="iconfont icon-DOC"></span>
  155. <span>咨询学习</span>
  156. <span>
  157. <span><a href="">器材</a></span>
  158. <span><a href="">大师</a></span>
  159. <span><a href="">学员</a></span>
  160. <span><a href="">实战</a></span>
  161. <span><a href="">大赛</a></span>
  162. <span><a href="">裤子</a></span>
  163. <span><a href="">影视</a></span>
  164. <span><a href="">其他</a></span>
  165. </span>
  166. <span class="iconfont icon-DOC"></span>
  167. <span>咨询学习</span>
  168. <span>
  169. <span><a href="">器材</a></span>
  170. <span><a href="">大师</a></span>
  171. <span><a href="">学员</a></span>
  172. <span><a href="">实战</a></span>
  173. <span><a href="">大赛</a></span>
  174. <span><a href="">裤子</a></span>
  175. <span><a href="">影视</a></span>
  176. <span><a href="">其他</a></span>
  177. </span>
  178. <span class="iconfont icon-DOC"></span>
  179. <span>咨询学习</span>
  180. <span>
  181. <span><a href="">器材</a></span>
  182. <span><a href="">大师</a></span>
  183. <span><a href="">学员</a></span>
  184. <span><a href="">实战</a></span>
  185. <span><a href="">大赛</a></span>
  186. <span><a href="">裤子</a></span>
  187. <span><a href="">影视</a></span>
  188. <span><a href="">其他</a></span>
  189. </span>
  190. </div>
  191. <div>
  192. <img src="images/1.jpg" alt="">
  193. <img src="images/banner-right.jpg" height="320" width="295"/>
  194. </div>
  195. </div>
  196. </body>
  197. </html>

附上代码,学了就自己做了一次,感觉代码还是有点臃肿,一些内容在盒子里面的精准移动与对齐还不太清楚,在目前的一些知识上感觉在内容上的移动,还有点欠缺,比如INPUT标签与搜索图片的移动上尝试了很久,才把搜索图标移动到INPUT框里面。

![![]



![]



以上是今天对于各FLEX属性的一些尝试,感觉有一定了解,但是还需要更多的实战,才能更加明白具体的使用方法




最后还复习了一下FLEX的内容,背下了一些属性单词以及用法,学习的好方法(笨方法)就是多写,多看,多读,只要做得多了,最后总有收获!

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