博客列表 >二手商品列表与评论与回复案例---PHP培训十期线上班

二手商品列表与评论与回复案例---PHP培训十期线上班

方小生
方小生原创
2019年12月29日 20:41:57606浏览

12月26日作业

目标:独立完成二手商品列表与评论回复,将写出自己的思路与实现方案

先看效果
商品列表与评论回复

整体分为三个组件,如图结构
文件结构

  1. 标题组件

实现:div盒子包裹文本,文本用span包裹(如果用h2标签,下部横线会很长),文本居中,设置上下内边距,下边框

demo示例

  1. <style>
  2. .title{
  3. padding:30px;
  4. text-align: center;
  5. }
  6. .title > span{
  7. font-size: 23px;
  8. border-bottom: 2px solid red;
  9. padding-bottom: 3px;
  10. }
  11. </style>
  12. <div class="title">
  13. <span>二手交易</span>
  14. </div>
  1. 商品列表组件

实现:整体分为两块(标题信息区域、商品区域),上面标题和导航区域不用使用flex,使用span和a链接,行内元素,水平排列;商品区域分为两个部分,使用flex布局,主轴方向横向;内部也是使用flex水平布局,可换行

demo示例:

  1. <style>
  2. /*商品列表区*/
  3. .shop_container{
  4. width: 1200px;
  5. background-color: #fff;
  6. margin:auto;
  7. padding: 15px;
  8. box-sizing: border-box;
  9. border-radius: 10px;
  10. }
  11. .shop_container:hover{
  12. box-shadow: 0 0 5px #888;
  13. }
  14. /*顶部信息*/
  15. .shop_container > .top-title{
  16. height: 50px;
  17. border-bottom: 1px solid #ccc;
  18. box-sizing: border-box;
  19. }
  20. .shop_container > .top-title>:first-child{
  21. font-size: 24px;
  22. margin-right: 20px;
  23. }
  24. .shop_container > .top-title>:nth-child(2){
  25. color:red;
  26. }
  27. /*区域导航*/
  28. .shop_container > .section-nav{
  29. height:55px;
  30. }
  31. .shop_container > .section-nav >span{
  32. font-size: 24px;
  33. color:red;
  34. padding-right:10px;
  35. }
  36. .shop_container > .section-nav > a{
  37. padding-left: 20px;
  38. }
  39. /*商品区域*/
  40. .shop_container > .main-list{
  41. height: 440px;
  42. display: flex;
  43. }
  44. /*左侧*/
  45. .shop_container > .main-list > .left{
  46. padding: 10px;
  47. width: 800px;
  48. display: flex;
  49. flex-flow: row wrap;
  50. justify-content: space-between;
  51. }
  52. .shop_container > .main-list > .left > .shop{
  53. width: 178px;
  54. height: 200px;
  55. display: flex;
  56. flex-flow: column nowrap;
  57. justify-content: space-between;
  58. }
  59. /*商品图片*/
  60. .shop_container > .main-list > .left > .shop img{
  61. width: 178px;
  62. border:1px solid #ccc;
  63. border-radius: 5px;
  64. }
  65. .shop_container > .main-list > .left > .shop > div {
  66. display: flex;
  67. }
  68. .shop_container > .main-list > .left > .shop span:first-of-type{
  69. color:red;
  70. }
  71. .shop_container > .main-list > .left > .shop span:last-of-type{
  72. background-color: lightgreen;
  73. color:white;
  74. padding:0 5px;
  75. margin-left:auto;
  76. }
  77. /*右侧快速入口*/
  78. .shop_container > .main-list > .right {
  79. flex-basis: 400px;
  80. padding: 10px;
  81. display:flex;
  82. flex-flow: row wrap;
  83. justify-content: space-between;
  84. }
  85. .shop_container > .main-list > .right >a img{
  86. width: 190px;
  87. height: 130px;
  88. }
  89. .shop_container > .main-list > .right > .ad img {
  90. width: 393px;
  91. height: 60px;
  92. }
  93. </style>
  94. <body>
  95. <div class="shop_container">
  96. <!--顶部信息-->
  97. <div class="top-title">
  98. <span>抢好货</span>
  99. <span>0低价,便捷,快速</span>
  100. </div>
  101. <!--区域导航-->
  102. <div class="section-nav">
  103. <span>热门分类</span>
  104. <a href="">美女写真</a>
  105. <a href="">日本美女</a>
  106. <a href="">美国美女</a>
  107. <a href="">国内美女</a>
  108. <a href="">AV美女</a>
  109. </div>
  110. <!--列表区域-->
  111. <div class="main-list">
  112. <!--左侧商品区域-->
  113. <div class="left">
  114. <div class="shop">
  115. <a href="">
  116. <img src="../../../img/9.jpg" alt="">
  117. </a>
  118. <a href="">
  119. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  120. </a>
  121. <div>
  122. <span>&yen345</span>
  123. <span>美女</span>
  124. </div>
  125. </div>
  126. <div class="shop">
  127. <a href="">
  128. <img src="../../../img/9.jpg" alt="">
  129. </a>
  130. <a href="">
  131. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  132. </a>
  133. <div>
  134. <span>&yen345</span>
  135. <span>美女</span>
  136. </div>
  137. </div>
  138. <div class="shop">
  139. <a href="">
  140. <img src="../../../img/9.jpg" alt="">
  141. </a>
  142. <a href="">
  143. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  144. </a>
  145. <div>
  146. <span>&yen345</span>
  147. <span>美女</span>
  148. </div>
  149. </div>
  150. <div class="shop">
  151. <a href="">
  152. <img src="../../../img/9.jpg" alt="">
  153. </a>
  154. <a href="">
  155. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  156. </a>
  157. <div>
  158. <span>&yen345</span>
  159. <span>美女</span>
  160. </div>
  161. </div>
  162. <div class="shop">
  163. <a href="">
  164. <img src="../../../img/9.jpg" alt="">
  165. </a>
  166. <a href="">
  167. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  168. </a>
  169. <div>
  170. <span>&yen345</span>
  171. <span>美女</span>
  172. </div>
  173. </div>
  174. <div class="shop">
  175. <a href="">
  176. <img src="../../../img/9.jpg" alt="">
  177. </a>
  178. <a href="">
  179. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  180. </a>
  181. <div>
  182. <span>&yen345</span>
  183. <span>美女</span>
  184. </div>
  185. </div>
  186. <div class="shop">
  187. <a href="">
  188. <img src="../../../img/9.jpg" alt="">
  189. </a>
  190. <a href="">
  191. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  192. </a>
  193. <div>
  194. <span>&yen345</span>
  195. <span>美女</span>
  196. </div>
  197. </div>
  198. <div class="shop">
  199. <a href="">
  200. <img src="../../../img/9.jpg" alt="">
  201. </a>
  202. <a href="">
  203. 大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖大甩卖
  204. </a>
  205. <div>
  206. <span>&yen345</span>
  207. <span>美女</span>
  208. </div>
  209. </div>
  210. </div>
  211. <!--右侧快速入口-->
  212. <div class="right">
  213. <a href=""><img src="../../../img/ad/1.png" alt=""></a>
  214. <a href=""><img src="../../../img/ad/2.png" alt=""></a>
  215. <a href=""><img src="../../../img/ad/3.png" alt=""></a>
  216. <a href=""><img src="../../../img/ad/4.png" alt=""></a>
  217. <div class="ad">
  218. <img src="../../../img/ad/image.png" alt="">
  219. <img src="../../../img/ad/ad2.jpg" alt="">
  220. </div>
  221. </div>
  222. </div>
  223. </div>
  224. </body>
  1. 评论回复组件

实现:整体分为两部分(评论和回复),使用flex,主轴方向垂直;中间头像和文本域也是使用flex;用户头像和用户回复信息使用flex横向布局,用户回复信息区域用flex垂直布局;最后一行使用margin-left=auto,需要将当前容器转为flex才有效;

demo示例

  1. <style>
  2. @import "../../../static/font/iconfont.css";
  3. .comment-replay{
  4. padding:15px;
  5. box-sizing: border-box;
  6. background-color: #fff;
  7. display: flex;
  8. flex-direction: column;
  9. }
  10. .top{
  11. display: flex;
  12. flex-flow: column nowrap;
  13. }
  14. .top h3{
  15. padding:20px 0;
  16. border-top:1px solid #ccc;
  17. }
  18. .top > div{
  19. display: flex;
  20. flex-flow: row nowrap;
  21. padding: 15px;
  22. height: 200px;
  23. }
  24. .comment-replay img{
  25. width: 60px;
  26. height: 60px;
  27. border-radius: 5px;
  28. }
  29. .top textarea{
  30. height: 200px;
  31. resize:none;
  32. margin-left:20px;
  33. flex:1;
  34. border-radius: 5px;
  35. }
  36. .top textarea:hover{
  37. box-shadow: 0 0 5px #ccc;
  38. }
  39. .top > button {
  40. font-size: 14px;
  41. background-color: #f64c59;
  42. border: none;
  43. color: white;
  44. width: 150px;
  45. height: 40px;
  46. align-self: end;
  47. cursor: pointer;
  48. }
  49. .top > button:hover{
  50. background-color: lightblue;
  51. box-shadow: 0 0 5px #888;
  52. }
  53. /*回复*/
  54. .comment-replay > .replay{
  55. display:flex;
  56. flex-flow: column nowrap;
  57. padding:10px 0;
  58. }
  59. .comment-replay > .replay > div{
  60. display:flex;
  61. align-items: center;
  62. margin-top:30px;
  63. }
  64. /*回复的内容区域*/
  65. .comment-replay > .replay > div>div{
  66. display:flex;
  67. flex-direction: column;
  68. margin-left:20px;
  69. height: 90px;
  70. justify-content: space-between;
  71. flex:1;
  72. }
  73. /*回复时间*/
  74. .comment-replay > .replay > div>div>div{
  75. display: flex;
  76. justify-content: space-between;
  77. }
  78. .comment-replay > .replay > div>div>div i{
  79. color:red;
  80. font-size:1.2rem;
  81. margin-right: 5px;
  82. }
  83. </style>
  84. <body>
  85. <div class="comment-replay">
  86. <div class="top">
  87. <h3>我要评论</h3>
  88. <div>
  89. <label for="comment">
  90. <img src="../../../static/images/user.png" alt="">
  91. </label>
  92. <textarea name="" id="comment" ></textarea>
  93. </div>
  94. <button>发表评论</button>
  95. </div>
  96. <div class="replay">
  97. <h3>最新回复</h3>
  98. <div>
  99. <img src="../../../static/images/user.png" alt="">
  100. <div>
  101. <span>用户昵称</span>
  102. <span>留言内容: php中文网,是一个有温度,有思想的学习平台</span>
  103. <div>
  104. <span>2019-12-12 15:34:23发表</span>
  105. <span><i class="iconfont icon-dianzan"></i>回复</span>
  106. </div>
  107. </div>
  108. </div>
  109. <div>
  110. <img src="../../../static/images/user.png" alt="">
  111. <div>
  112. <span>用户昵称</span>
  113. <span>留言内容: php中文网,是一个有温度,有思想的学习平台</span>
  114. <div>
  115. <span>2019-12-12 15:34:23发表</span>
  116. <span><i class="iconfont icon-dianzan"></i>回复</span>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </body>

ps:不知道为什么写这个写了好几个小时,大概布局其实也不难,就是具体尺寸和定宽大小不清楚,后面调整细节花了些时间^_^

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