使用flex布局平分宽度

css3 父元素 display:flex; 子元素给定flex占比 1的时候子元素平分

.color_container {
    width: 100%;
    height: 22px;
    display: flex;
    flex-direction: row
}
.color_container>div{
    height: 22px;
    flex: 1;
}
  <div class="color_container">
             <div title="紫色" style="background-color: rgb(121, 56, 106);"></div>
             <div title="蓝色" style="background-color: rgb(57, 107, 179);"></div>
              <div title="绿色" style="background-color: rgb(152, 203, 104);"></div>
              <div title="黄色" style="background-color: rgb(251, 220, 4);"></div>
              <div title="橙色" style="background-color: rgb(243, 121, 32);"></div>
              <div title="红色" style="background-color: rgb(202, 33, 40);"></div>
   </div>

猜你喜欢

转载自blog.csdn.net/weixin_38570967/article/details/81636775