Blogger Information
Blog 3
fans 0
comment 1
visits 2273
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
补交12.27作业--flex布局
艾云技术博客
Original
606 people have browsed it

事情太多了,昨天视频里讲的晚上就练习了一遍,今天没带,就在排版公司一个项目的页面上试用了一下flex,顺便实战练习了一下

页面效果展示

虽然说简单,但是练习了一下,这只是项目的其中一个页面的一小部分,后面还有很多页面

代码部分

HTML
  1. <section id="pro-nei">
  2. <div class="title" aos="fade-down" aos-easing="linear" aos-duration="800">
  3. <span>产品展示</span>
  4. <span>DRINKS SHOW</span>
  5. </div>
  6. <div class="pro-cat" aos="fade-down" aos-easing="linear" aos-duration="800">
  7. <a href="">果汁饮料系列</a>
  8. <a href="">果酱系列</a>
  9. <a href="">风味饮料系列</a>
  10. <a href="">牛奶系列</a>
  11. <a href="">五谷养生系列</a>
  12. <a href="">果维伴侣系列</a>
  13. <a href="">茶系列</a>
  14. <a href="">奶茶系列</a>
  15. <a href="">咖啡可可系列</a>
  16. <a href="">冰淇淋系列</a>
  17. </div>
  18. <div class="pro-cent">
  19. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  20. <img src="img/pro-nei.jpg" width="">
  21. <span>香橙蜜桃果汁饮料浓浆</span>
  22. </div>
  23. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  24. <img src="img/pro-nei.jpg" width="">
  25. <span>香橙蜜桃果汁饮料浓浆</span>
  26. </div>
  27. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  28. <img src="img/pro-nei.jpg" width="">
  29. <span>香橙蜜桃果汁饮料浓浆</span>
  30. </div>
  31. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  32. <img src="img/pro-nei.jpg" width="">
  33. <span>香橙蜜桃果汁饮料浓浆</span>
  34. </div>
  35. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  36. <img src="img/pro-nei.jpg" width="">
  37. <span>香橙蜜桃果汁饮料浓浆</span>
  38. </div>
  39. <div class="intro" aos="fade-down" aos-easing="linear" aos-duration="800">
  40. <img src="img/pro-nei.jpg" width="">
  41. <span>香橙蜜桃果汁饮料浓浆</span>
  42. </div>
  43. </div>
  44. </section>
CSS
  1. /* pronei */
  2. #pro-nei{
  3. display: flex;
  4. flex-direction: column;
  5. width: 1200px;
  6. margin: 0 auto;
  7. }
  8. #pro-nei .title{
  9. margin-top: 120px;
  10. display: flex;
  11. flex-direction: column;
  12. text-align: center;
  13. }
  14. #pro-nei .title > span:first-of-type{
  15. font-size: 29px;
  16. font-weight: bold;
  17. color: #4fbe48;
  18. }
  19. #pro-nei .title > span:last-of-type{
  20. font-size: 15px;
  21. margin-top: 5px;
  22. color: #a8a8a8;
  23. }
  24. #pro-nei > .pro-cat {
  25. display: flex;
  26. flex-flow: row wrap;
  27. width: 800px;
  28. margin: 35px auto;
  29. justify-content: space-between;
  30. }
  31. #pro-nei > .pro-cat a{
  32. width: 19.8%;
  33. text-align: center;
  34. border-right: 1px solid #888;
  35. margin-top: 15px;
  36. font-size: 15px;
  37. }
  38. #pro-nei > .pro-cat a:hover{
  39. color: #4AB344;
  40. }
  41. #pro-nei > .pro-cat a:nth-last-of-type(6),#pro-nei > .pro-cat a:last-of-type{
  42. border: none;
  43. }
  44. #pro-nei .pro-cent{
  45. display: flex;
  46. flex-flow: row wrap;
  47. justify-content: space-between;
  48. width: 1130px;
  49. margin: 35px auto 178px auto;
  50. }
  51. #pro-nei .pro-cent > .intro{
  52. width: 368px;
  53. height: 348px;
  54. margin-top: 15px;
  55. overflow: hidden;
  56. display: flex;
  57. flex-direction: column;
  58. position: relative;
  59. }
  60. #pro-nei .pro-cent > .intro img{
  61. width: 100%;
  62. transition: all 0.6s;
  63. }
  64. #pro-nei .pro-cent > .intro img:hover{
  65. transform: scale(1.2);
  66. }
  67. #pro-nei .pro-cent > .intro >span{
  68. position: absolute;
  69. bottom: 0;
  70. background: rgba(0,0,0,.6);
  71. color: #fff;
  72. width: 100%;
  73. padding: 10px 5px;
  74. display: none;
  75. }
  76. #pro-nei .pro-cent > .intro:hover span{
  77. display: block;
  78. }

虽然说做了一个小功能用到的关于flex内容不多,但是我发现了很多

我发现flex使用起来首先非常方便,就是这个才让我省去一大半时间,
我有一个理解思路不知道可不可以这样理解,因为我这个小案例就是用这个思路写出来的,还请老师帮我纠正一下这个思路,
思路是:比如

  1. <!--父子div-->
  2. <div class="a">
  3. <div class='b'></div>
  4. <div class='b'></div>
  5. <div class='b'></div>
  6. <div class='b'></div>
  7. <div class='b'></div>
  8. </div>
  9. <!--
  10. 如果我想让‘class=b’的所有元素横向排列或垂直排列(大体上看效果图的展示效果确定横向或竖向),
  11. 那么我使用flex就更为方便,不管有多少层,其实质就是一个div套div flex套flex的结构,呃...我也说不上来,口才不好
  12. -->

最后想问下,如果我想布局的列表样式为

因为最后还需要调用循环,所以怎么利用css把他排列成这种样式呢?

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