<div class="hello">
<div class="common">1</div>
<div class="common">2</div>
<div class="common">3</div>
</div>
<style>
.hello {
width: 100%;
display: flex;
}
//第一种:flex:1
//第二种:width: calc(100% / 3);
.common {
flex: 1;
/* width: calc(100% / 3); */
}
.common:nth-child(odd) {
background-color: pink;
}
.common:nth-child(even) {
background-color: yellow;
}
</style>
实现自适应等宽
最新推荐文章于 2022-11-03 18:28:41 发布