您当前位置: 首页 >  WEB技术 >  推荐CSS3使用flex布局平分宽度,非常好用。
2023/10/24 13:24:26 分类:WEB技术

推荐CSS3使用flex布局平分宽度,非常好用。

父元素 display:flex; 子元素给定flex占比 1的时候子元素平分
.color_container {
    width: 100%;
    height: 22px;
    display: flex;
    flex-direction: row
}
.color_container>div{
    height: 22px;
    flex: 1;
}

HTML代码部分

  <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>


本文由胡金金个人网站2023年10月24日整理发布,转载注明:http://www.hujinjin.com/info/17378.html

凡标明来源于胡金金个人网站的文章,皆为本站整理发布,若转载此文必须附原文链接,对部分平台更改其文内容当自己原创者,胡金金个人网站将保留其追究权利!
个人资讯推荐
友情链接