当前位置:   article > 正文

使用div+css实现表格布局_div实现表格布局

div实现表格布局

DIV+CSS是WEB设计标准,它是一种网页的布局方法。与传统中通过表格(table)布局定位的方式不同,它可以实现网页页面内容与表现相分离。提起DIV+CSS组合,还要从XHTML说起。XHTML是一种在HTML标准通用标记语言的子集)基础上优化和改进的新语言,目的是基于XML应用与强大的数据转换能力,适应未来网络应用更多的需求。

“DIV+CSS”其实是错误的叫法,而标准的叫法应是XHTML+CSS。因为DIV与Table都是XHTML或HTML语言中的一个标记,而CSS只是一种表现形式。也许其提出者本意并没有错,但是跟风者从表现曲解了其意思,认为整个页面就应当是DIV+CSS文件的组合。

css是层叠样式表(Cascading Style Sheets)的缩写,用于定义HTML元素的显示形式,是W3C推出的格式化网页内容的标准技术。网页设计者必须掌握的技术之一。

HTML文档中加入CSS

样式表可分为嵌入式样式表、外部样式表和内联样式表三种,在同一文档内可以同时使用三种方法。

1.样式定义放在一个单独的文件中,例:新建一个后辍为CSS的样式定义。

元素{ 属性color:值red;} 在head段使用<link>标记,

引用语法:<link rel=”stylesheet” type=”text/css” href=”样式表URL” />

2.嵌入式样式表:

<style>元素段必须出现在head段内,有一个开始和结束标记,并且可以有多个<style>段

语法格式: <style type=”text/css”>

…样式定义…

样式

3.在嵌入式样式表中我们可以使用@import导入一个外部样式表,例:

<style type=”text/css”>

@import url(外部样式表位置);

…其它嵌入式的样式定义…

</style>

4.内联样式表:

写在开始标记里面,比如你要H1变红色,

<h1 style=”color:red;”>变为红色</h1>

总结: 三种样式表优先使用外部样式表、嵌入式样式表用来调试用的、一般不使用内联样式表。

5.样式规则:

一个样式规则由一个选择器后跟一个声明块组成,声明块是一个大容器,由大括号中间的部分组成,声明块中间的空间会被忽略,,声明块由一个一个的声明组成,声明由属性和值组成,属性和值用冒号隔开,分号结束,每个声明内只能有一个属性,如果属性值中含有空格用双引号括起来例,在一个声明块内可以有多个声明,每个声明用分号隔开。


用于element ui的tabel组件无法实现的特殊表格布局,如下:

 .vue文件:

  1. <template>
  2. <basic-container>
  3. <div class="m-order-list-wrap">
  4. <div class="table_box">
  5. <div class="m-order-list-table-wrap-outer">
  6. <div class="m-order-list-table-wrap">
  7. <!-- 表头 -->
  8. <div class="m-order-list-header-wrap">
  9. <div class="m-order-list-header-item">所属渠道</div>
  10. <div class="m-order-list-header-item">商品名称</div>
  11. <div
  12. class="m-order-list-header-item-width"
  13. style="width: 120px"
  14. >
  15. 商品金额
  16. </div>
  17. <div
  18. class="m-order-list-header-item-width"
  19. style="width: 120px"
  20. >
  21. 商品数量
  22. </div>
  23. <div
  24. class="m-order-list-header-item-width"
  25. style="width: 120px"
  26. >
  27. 支付金额
  28. </div>
  29. <div
  30. class="m-order-list-header-item-width"
  31. style="width: 120px"
  32. >
  33. 支付方式
  34. </div>
  35. <div
  36. class="m-order-list-header-item-width"
  37. style="width: 120px"
  38. >
  39. 订单状态
  40. </div>
  41. <div
  42. class="m-order-list-header-item-width"
  43. style="width: 120px"
  44. >
  45. 物流状态
  46. </div>
  47. <div
  48. class="m-order-list-header-item-width"
  49. style="width: 120px"
  50. >
  51. 操作
  52. </div>
  53. </div>
  54. <!-- 列表内容 -->
  55. <div class="m-order-list-content-wrap">
  56. <div
  57. v-for="item in tableData"
  58. :key="item.channel_order_no"
  59. class="m-order-list-content-item"
  60. >
  61. <div class="m-order-list-content-item-left">
  62. <!-- 基础信息 -->
  63. <div class="m-order-list-content-item-header">
  64. <div class="m-order-list-content-item-header-inner">
  65. <span class="m-order-list-desc-label">店铺名称</span>
  66. <span class="m-order-list-desc-value-header">{{
  67. item.shop_name
  68. }}</span>
  69. <div>
  70. <div style="margin: 0 0 4px 0">
  71. <span class="m-order-list-desc-label"
  72. >渠道订单号</span
  73. >
  74. <span class="m-order-list-desc-value-header">{{
  75. item.channel_order_no
  76. }}</span>
  77. </div>
  78. <div>
  79. <span
  80. class="m-order-list-desc-label"
  81. style="width: 62px; text-align: right"
  82. >分销单号</span
  83. >
  84. <span class="m-order-list-desc-value-header">{{
  85. item.order_no
  86. }}</span>
  87. </div>
  88. </div>
  89. <span class="m-order-list-desc-label">下单时间</span>
  90. <span class="m-order-list-desc-value-header">{{
  91. item.order_create_at
  92. }}</span>
  93. <span class="m-order-list-desc-label">手机号</span>
  94. <span class="m-order-list-desc-value-header">{{
  95. item.place_order_phone
  96. }}</span>
  97. <span class="m-order-list-desc-label">买家/收货人</span>
  98. <span class="m-order-list-desc-value-header">{{
  99. item.place_order_nickname
  100. }}</span>
  101. </div>
  102. </div>
  103. <!-- 列表单元格 -->
  104. <div class="m-order-list-content-item-info">
  105. <!-- 所属渠道 -->
  106. <div class="m-order-list-col">
  107. <span class="m-order-list-desc-value-info">{{
  108. item.channel_name
  109. }}</span>
  110. </div>
  111. <!-- 商品名称 -->
  112. <div class="m-order-list-col">
  113. <span class="m-order-list-desc-value-info">{{
  114. item.product_name
  115. }}</span>
  116. </div>
  117. <!-- 商品金额 -->
  118. <div class="m-order-list-col-width" style="width: 120px">
  119. <span class="m-order-list-desc-value-info">{{
  120. item.order_amount
  121. }}</span>
  122. </div>
  123. <!-- 商品数量 -->
  124. <div class="m-order-list-col-width" style="width: 120px">
  125. <span class="m-order-list-desc-value-info">{{
  126. item.product_quantity
  127. }}</span>
  128. </div>
  129. <!-- 支付金额 -->
  130. <div class="m-order-list-col-width" style="width: 120px">
  131. <span class="m-order-list-desc-value-info">{{
  132. item.pay_amount
  133. }}</span>
  134. </div>
  135. <!-- 支付方式 -->
  136. <div class="m-order-list-col-width" style="width: 120px">
  137. <span
  138. :class="[
  139. `m-order-list-desc-value-info m-order-list-pay-type ${getPayTypeStatusClass(
  140. item
  141. )}`,
  142. ]"
  143. >{{ item.pay_type_name }}</span
  144. >
  145. </div>
  146. <!-- 订单状态 -->
  147. <div class="m-order-list-col-width" style="width: 120px">
  148. <span
  149. :class="[
  150. `m-order-list-desc-value-info m-order-list-status ${getOrderStatusClass(
  151. item
  152. )}`,
  153. ]"
  154. >{{ item.order_status_name }}</span
  155. >
  156. </div>
  157. <!-- 物流状态 -->
  158. <div class="m-order-list-col-width" style="width: 120px">
  159. <span
  160. :class="[
  161. `m-order-list-desc-value-info m-order-express-type ${getExpressStatusClass(
  162. item
  163. )}`,
  164. ]"
  165. >{{ item.logistics_status_name }}</span
  166. >
  167. </div>
  168. </div>
  169. </div>
  170. <div class="m-order-list-operation" style="width: 120px">
  171. <el-button
  172. @click="handleEditModalVisible(item)"
  173. type="text"
  174. size="small"
  175. v-if="permission.orderAfterSale"
  176. >售后</el-button
  177. >
  178. <el-button
  179. @click="handleJumpToDetail(item)"
  180. type="text"
  181. size="small"
  182. v-if="permission.orderDetail"
  183. >详情</el-button
  184. >
  185. </div>
  186. </div>
  187. </div>
  188. <div v-if="tableData.length === 0">
  189. <emptyData></emptyData>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </basic-container>
  196. </template>

 index.css:

  1. .m-tools-push-group {padding: 10px 10px 10px 0;box-shadow: 0 2px 12px 0 rgba(8, 2, 94, 0.5);margin: 5px 0 20px;border-radius: 10px;}
  2. .m-entity-table .el-col-12{min-width: 490px;max-width: 490px;}
  3. .m-entity-value{display: inline-block; width: 100px; white-space: break-spaces; vertical-align: top;}
  4. .m-order-list-row{display:flex;padding:8px 5px;line-height:20px;}
  5. .m-order-list-row.border1{border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  6. .m-order-list-row.border2{border-right: 1px solid #EBEEF5;}
  7. .m-order-list-row.border3{border-bottom: 1px solid #EBEEF5;}
  8. .m-order-list-row-color{background: rgb(238, 241, 248);}
  9. .m-order-list-search .el-row{margin: 0;}
  10. .m-order-list-search .el-col{margin: 0;}
  11. .m-order-list-desc-label{display:inline-block;font-size:12px;font-weight:400;margin:0 10px 0 0;white-space:nowrap;text-align:left;color:#000}
  12. .m-order-list-desc-label::after{content:':'}
  13. .m-order-list .el-table__row.expanded{display: none;}
  14. .m-order-list .el-table__expanded-cell{padding: 0 0 0 50px!important;}
  15. .m-order-list .el-table_1_column_1:first-child{display: inline-block;width: 1px;}
  16. .m-order-list-table-wrap-outer{overflow-x: auto;}
  17. .m-order-list-table-wrap{border-top: 1px solid #EBEEF5;border-left: 1px solid #EBEEF5;min-width: 1089px;}
  18. .m-order-list-header-wrap{display: flex;padding:0;color: rgba(0,0,0,.85);font-size: 12px;font-weight: 700;background: #fafafa;line-height: 40px;}
  19. .m-order-list-header-item{ flex: 1;min-width: 120px; text-align: center;border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  20. .m-order-list-header-item-width{min-width: 120px; text-align: center;border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  21. .m-order-list-content-item{display: flex; color: #606266;font-size: 12px;}
  22. .m-order-list-content-item:nth-child(even){background: #F5F7FA;}
  23. .m-order-list-content-item:hover{background: #eff6ff;}
  24. .m-order-list-content-item-left{flex: 1;}
  25. .m-order-list-content-item-header{display: flex;padding:15px 10px;border-bottom: 1px solid #EBEEF5;border-right: 1px solid #EBEEF5;}
  26. .m-order-list-content-item-header-inner{display: flex;}
  27. .m-order-list-desc-value-header{display:inline-block;margin: 0 10px 0 0; vertical-align:top;font-size:12px;font-weight:400;word-break:break-all;text-align:justify;color:#333;}
  28. .m-order-list-content-item-info{display: flex;padding:0;}
  29. .m-order-list-col{flex:1;min-width: 120px; display: flex;border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  30. .m-order-list-col-width{display: flex;min-width: 120px; border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  31. .m-order-list-desc-value-info{display:inline-block;padding: 0 2px;vertical-align:top;font-size:12px;font-weight:400;flex:1;line-height: 40px; word-break:break-all;text-align:justify;color:#333;text-align: center;}
  32. .m-order-list-operation{display:flex;align-items: center;justify-content: center; vertical-align:top;font-size:12px;font-weight:400;line-height: 40px; word-break:break-all;text-align:justify;color:#333;text-align: center;border-right: 1px solid #EBEEF5;border-bottom: 1px solid #EBEEF5;}
  33. .m-order-list-pagination{text-align: right;padding: 20px 5px;}
  34. /* .m-order-list-search .el-col-12{min-width: 490px;max-width: 490px;} */
  35. .m-order-list-time-range-item{max-width: 490px!important;}
  36. .m-order-list-pagination .el-pagination.is-background .el-pager li:not(.disabled).active {background-color: #e5e4ed !important;color: #666 !important;}
  37. .m-order-list-pagination .el-pagination.is-background .el-pager li {background-color: #fff;border: 1px solid #dddddd;border-radius: 6px;}
  38. .m-order-list-status{font-weight: bold;color: #409EFF;}
  39. .m-order-list-status.done{color: #67C23A;}
  40. .m-order-list-status.unpaid{color: #6600cc;}
  41. .m-order-list-status.wait_deliver{color: #ff9900;}
  42. .m-order-list-status.refund_all{color: #663399;}
  43. .m-order-list-status.refund_part{color: #cc33cc;}
  44. .m-order-list-status.cancel_time{color: #cc3333;}
  45. .m-order-list-status.cancel_user{color: #996633;}
  46. .m-order-list-pay-type{font-weight: bold;color: #409EFF;}
  47. .m-order-list-pay-type.wechat{color: #67C23A;}
  48. .m-order-list-pay-type.zhifubao{color: #1677ff;}
  49. .m-order-list-pay-type.doudian{color: #ff6600;}
  50. .m-order-list-pay-type.banxuejin{color: #9900ff;}
  51. .m-order-express-type{font-weight: bold;color: #409EFF;}
  52. .m-order-express-type.unsend{color: #666666;}
  53. .m-order-express-type.done{color: #67C23A;}
  54. .m-order-express-type.wechat{color: #67C23A;}
  55. .m-order-express-type.wechat{color: #67C23A;}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/767475
推荐阅读
相关标签
  

闽ICP备14008679号