博客列表 >12月26日网站各个组件的实战,以及FLEX的具体应用

12月26日网站各个组件的实战,以及FLEX的具体应用

曾
原创
2019年12月27日 17:18:08624浏览

今天继续实战前端网页的各类型组件编写,以及FLEX弹性盒子的运用。

这个组件主要是运用FLEX弹性盒子,嵌套完成,主要使用到Flex-flow:row|column;nowarp|warp来实现FLEX项目的排列方式以及是否换行。
运用justify-content来实现Flex项目的对齐方式,这次的组件对齐方式主要是运用justify-content:space-between来实现的两端对齐。

  1. <div class="public-second-hand">
  2. <!-- 标题1-->
  3. <div class="title1">
  4. <a href="">抢好货</a>
  5. <span>0低价</span>
  6. <span>便捷</span>
  7. <span>安全</span>
  8. <span>快速</span>
  9. </div>
  10. <!-- 标题2-->
  11. <div class="title2">
  12. <span>热门分类</span>
  13. <a href="">美女写真</a>
  14. <a href="">日本美女</a>
  15. <a href="">美国美女</a>
  16. <a href="">国内美女</a>
  17. <a href="">AV美女</a>
  18. </div>
  19. <!-- 交易内容-->
  20. <div class="exhibition">
  21. <!-- 交易内容左边-->
  22. <div class="exhibition-lt">
  23. <div class="exhibition-lt-shop">
  24. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  25. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  26. <div>
  27. <spa>&yen;333</spa>
  28. <span>美女</span>
  29. </div>
  30. </div>
  31. <div class="exhibition-lt-shop">
  32. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  33. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  34. <div>
  35. <spa>&yen;333</spa>
  36. <span>美女</span>
  37. </div>
  38. </div>
  39. <div class="exhibition-lt-shop">
  40. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  41. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  42. <div>
  43. <spa>&yen;333</spa>
  44. <span>美女</span>
  45. </div>
  46. </div>
  47. <div class="exhibition-lt-shop">
  48. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  49. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  50. <div>
  51. <spa>&yen;333</spa>
  52. <span>美女</span>
  53. </div>
  54. </div>
  55. <div class="exhibition-lt-shop">
  56. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  57. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  58. <div>
  59. <spa>&yen;333</spa>
  60. <span>美女</span>
  61. </div>
  62. </div>
  63. <div class="exhibition-lt-shop">
  64. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  65. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  66. <div>
  67. <spa>&yen;333</spa>
  68. <span>美女</span>
  69. </div>
  70. </div>
  71. <div class="exhibition-lt-shop">
  72. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  73. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  74. <div>
  75. <spa>&yen;333</spa>
  76. <span>美女</span>
  77. </div>
  78. </div>
  79. <div class="exhibition-lt-shop">
  80. <img src="../../static/images/shop/shop5.jpg" alt="" width="178" height="122">
  81. <span>美女性感写真海报墙艺术装饰画帖画图1</span>
  82. <div>
  83. <spa>&yen;333</spa>
  84. <span>美女</span>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- 交易内容右边-->
  89. <div class="exhibition-rt">
  90. <a href=""><img src="../../static/images/ad/1.png" alt="" width="190" height="130"></a>
  91. <a href=""><img src="../../static/images/ad/2.png" alt="" width="190" height="130"></a>
  92. <a href=""><img src="../../static/images/ad/3.png" alt="" width="190" height="130"></a>
  93. <a href=""><img src="../../static/images/ad/4.png" alt="" width="190" height="130"></a>
  94. <div class="exhibition-rt-ad2">
  95. <a href=""><img src="../../static/images/ad/image.png" alt=""width="393" height="60"></a>
  96. <a href=""><img src="../../static/images/ad/ad2.jpg" alt="" width="393" height="60"></a>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  1. .public-second-hand {
  2. width: 1200px;
  3. margin: auto;
  4. padding: 10px;
  5. border-radius: 3px;
  6. box-sizing: border-box;
  7. background-color: #fff;
  8. }
  9. .public-second-hand:hover{
  10. box-shadow: 0 0 3px;
  11. }
  12. .public-second-hand > div{
  13. margin: 10px 0;
  14. }
  15. .public-second-hand >.title1{
  16. height: 40px;
  17. border-bottom: 1px solid lightgray;
  18. }
  19. .public-second-hand >.title1 > a {
  20. font-size: 24px;
  21. color: black;
  22. margin-right: 20px;
  23. }
  24. .public-second-hand >.title1 > span {
  25. color: red;
  26. }
  27. .public-second-hand >.title2{
  28. height: 40px;
  29. }
  30. .public-second-hand >.title2 >span{
  31. font-size: 24px;
  32. color: red;
  33. }
  34. .public-second-hand >.title2 >a{
  35. color: black;
  36. margin: 0 10px;
  37. }
  38. .public-second-hand >.title2 > a:hover{
  39. color: #DD4A68;
  40. }
  41. .public-second-hand >.exhibition{
  42. height: 440px;
  43. display: flex;
  44. }
  45. .public-second-hand >.exhibition >.exhibition-lt{
  46. flex-basis: 800px;
  47. padding: 10px;
  48. display: flex;
  49. flex-flow: row wrap;
  50. justify-content: space-between;
  51. }
  52. .public-second-hand >.exhibition >.exhibition-lt>.exhibition-lt-shop{
  53. width: 178px;
  54. height: 200px;
  55. display: flex;
  56. flex-flow: column nowrap;
  57. justify-content: space-between;
  58. }
  59. .public-second-hand >.exhibition >.exhibition-lt>.exhibition-lt-shop>img{
  60. border-radius: 5px;
  61. border: 1px solid #cccccc;
  62. }
  63. .public-second-hand >.exhibition >.exhibition-lt>.exhibition-lt-shop>div{
  64. display: flex;
  65. justify-content: space-between;
  66. }
  67. .public-second-hand >.exhibition >.exhibition-lt>.exhibition-lt-shop>div>span:first-child{
  68. color: red;
  69. }
  70. .public-second-hand >.exhibition >.exhibition-lt>.exhibition-lt-shop>div>span:nth-last-child(1){
  71. color: white;
  72. padding: 0 5px;
  73. background-color: lightgreen;
  74. }
  75. .public-second-hand >.exhibition >.exhibition-rt{
  76. flex-basis: 400px;
  77. padding: 10px;
  78. display: flex;
  79. flex-flow: row wrap;
  80. justify-content: space-between;
  81. }
  82. .public-second-hand >.exhibition >.exhibition-rt >.exhibition-rt-ad2{
  83. display: flex;
  84. flex-flow: column;
  85. }

效果图,两端对齐剩余空间再平均分配给项目左右,自然间距就出来了(前提是有剩余空间可供分配)

评论区主要使用了flex-flow:column垂直排列方式,来实现的效果,评论列表以多个Flex弹性盒子嵌套完成,button按钮组件使用align-self实现单个项目的对齐方式嵌套多个flex盒子完成。(Flex弹性盒子下面可以嵌套很多个Flex,不建议嵌套多了,以免混乱)

分页区比较简单,使用Flex把A标签变为弹性盒子,使用justify-content:center实现居中效果

代码都是写完了,有些排版不一样,然后在根据老师的代码 进行修改,大体架构是清楚了,还需要多加磨炼。

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议