vue实现弹性布局,横向超出则可滚动,并且隐藏滚动条

您所在的位置:网站首页 el-table滚动条隐藏 vue实现弹性布局,横向超出则可滚动,并且隐藏滚动条

vue实现弹性布局,横向超出则可滚动,并且隐藏滚动条

2023-04-13 10:27| 来源: 网络整理| 查看: 265

代码:

export default { data(){ return{ cj:1, } }, methods:{ } } .flexStyle{ height:100px; display:flex; justify-content:space-between; /* 设置超出滚动 */ overflow-x:auto; } .contentStyle{ width:50px; height:50px; display:inline-block; background:#a3a2a2; margin-right:5px; /* 超出滚动的关键,没有它元素会自动缩小,不会滚动 */ flex-shrink: 0; } ::-webkit-scrollbar { /* 隐藏滚动条 */ display: none; }

效果: 弹性布局左右滑动无滚动条.gif

复习弹性布局的各个属性: justify-content:默认值flex-start

/* Positional alignment */ justify-content: center; /* 居中排列 */ justify-content: start; /* Pack items from the start */ justify-content: end; /* Pack items from the end */ justify-content: flex-start; /* 从行首起始位置开始排列 */ justify-content: flex-end; /* 从行尾位置开始排列 */ justify-content: left; /* Pack items from the left */ justify-content: right; /* Pack items from the right */ /* Baseline alignment */ justify-content: baseline; justify-content: first baseline; justify-content: last baseline; /* Distributed alignment */ justify-content: space-between; /* 均匀排列每个元素 首个元素放置于起点,末尾元素放置于终点 */ justify-content: space-around; /* 均匀排列每个元素 每个元素周围分配相同的空间 */ justify-content: space-evenly; /* 均匀排列每个元素 每个元素之间的间隔相等 */ justify-content: stretch; /* 均匀排列每个元素 'auto'-sized 的元素会被拉伸以适应容器的大小 */ /* Overflow alignment */ justify-content: safe center; justify-content: unsafe center; /* Global values */ justify-content: inherit; justify-content: initial; justify-content: unset;

flex-shrink:该属性指定了 flex 元素的收缩规则,默认值为1。flex 元素仅在默认宽度之和大于容器的时候才会发生收缩,其收缩的大小是依据 flex-shrink 的值。flex-shrink值越大,收缩程度越高,值为0不收缩



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3