1
2
当前位置:   article > 正文

flex布局中flex-shrink的使用_flex-shrink 怎么用

flex-shrink 怎么用
<div style="width: 1000px;overflow: auto;display: flex;border: 1px solid black">
   <div style="width: 500px;height: 100px;background-color: red;">1</div>
   <div style="width: 500px;height: 100px;background-color: green;">2</div>
   <div style="width: 500px;height: 100px;background-color: blue;">3</div>
   <div style="width: 500px;height: 100px;background-color: orange;">4</div>
   <div style="width: 500px;height: 100px;background-color: pink;">5</div>
</div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

在这里插入图片描述

在给他子元素不加flex-shrink且父盒子中不加flex-wrap=“wrap”的情况下,超出父盒子的宽度,父盒子会自动压缩子盒子的宽度。

当给子盒子加上flex-shrink: 0,子盒子不会被压缩宽度;

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签