一、flex布局方法和属性教程
1、参考链接flex布局教程;
2、简单理解
01--容器属性
- flex-direction 左右,上下布局
- flex-wrap 是否换行,反向换行
- flex-flow 包含flex-direction和flex-wrap 属性
- justify-content 项目(子元素)是否水平居中
- align-items 项目(子元素)是否水平居中
- align-content 项目(子元素)多根轴线(多列)是否水平居中
03--项目属性
- order 子元素排列顺序
- flex-grow 子元素放大,默认等比
- flex-shrink 子元素缩小,默认等比
- flex-basis 可以设定子元素固定大小
- flex flex-grow, flex-shrink 和 flex-basis的简写
- align-self 子元素自定义垂直对齐方式
flex绘制table表格,支持文字自动换行,高度自适应(宽度固定)
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="table">
<div class="flex-box header">
<div class="flex-cell1 border-rb">
<div>序号XXXXXXXXXXXXXXXXXX</div>
</div>
<div class="flex-cell2 border-rb">配件名称xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div class="flex-cell3 border-rb">
<div class="lossAssessment">
<div>
<div>定损xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
</div>
</div>
<div class="lossAssessmentContent">
<div class="price border-tr" >价格</div>
<div class="count border-t">数量</div>
</div>
</div>
<div class="flex-cell4 border-b">
<div>
<div>小计</div>
</div>
</div>
</div>
<div class="flex-box tableBody">
<div class="flex-row">
<div class="flex-cell1 border-rb">序号XXXXXXXXXXXXXXXXXXXX</div>
<div class="flex-cell2 border-rb">配件名称</div>
<div class="flex-cell3 border-rb">价格</div>
<div class="flex-cell4 border-rb">数量</div>
<div class="flex-cell5 border-rb">小计</div>
</div>
<div class="flex-row">
<div class="flex-cell1 border-rb">序号</div>
<div class="flex-cell2 border-rb">配件名称</div>
<div class="flex-cell3 border-rb">价格</div>
<div class="flex-cell4 border-rb">数量</div>
<div class="flex-cell5 border-rb">小计</div>
</div>
<div class="flex-row">
<div class="flex-cell1 border-rb">序号</div>
<div class="flex-cell2 border-rb">配件名称</div>
<div class="flex-cell3 border-rb">价格</div>
<div class="flex-cell4 border-rb">数量xxxxxxxxxxxxxxxxxxxxxx</div>
<div class="flex-cell5 border-rb">
小计
</div>
</div>
</div>
</div>
<style lang="scss">
.table{
width: 300px;
border: 1px solid #666;
word-wrap: break-word;
margin: 0 auto;
.header{
/* width: 300px; */
display: flex;
flex-direction: row;
flex-wrap: nowrap;
color: #666;
font-size: 14px;
text-align: center;
box-sizing: border-box;
.flex-cell1{
width: 50px;
}
.flex-cell2{
width: 100px;
}
.flex-cell3{
width: 100px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
.lossAssessment{
width: 100%;
}
.lossAssessmentContent{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.price{
width: 50px;
}
.count{
width: 50px;
}
}
}
.flex-cell4{
width: 50px;
}
}
.tableBody{
.flex-row{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
color: #666;
font-size: 14px;
text-align: center;
box-sizing: border-box;
.flex-cell1{
width: 50px;
}
.flex-cell2{
width: 100px;
}
.flex-cell3{
width: 50px;
}
.flex-cell4{
width: 50px;
}
.flex-cell5{
width: 50px;
}
.border-rb:last-child{
border-right: none !important;
}
}
.flex-row:last-child{
.border-rb{
border-bottom: none !important;
}
}
}
.border-t{
border-top: 1px solid #666;
box-sizing: border-box;
}
.border-tr{
border-right: 1px solid #666;
border-top: 1px solid #666;
box-sizing: border-box;
}
.border-rb{
border-right: 1px solid #666;
border-bottom: 1px solid #666;
box-sizing: border-box;
}
.border-b{
border-bottom: 1px solid #666;
box-sizing: border-box;
}
}
</style>
</body>
</html>