javascript - 使用 CSS 滑动按钮/菜单
问题描述
这是 300 像素宽度的容器中的六个按钮。如您所见,由于预期空间不足,按钮正在跳入新行。我想知道是否有办法将按钮保持在一条线上,但有可能在移动设备上将它们向右滑动?方框阴影表示右侧有更多按钮。
.wrap {
width: 300px;
box-shadow: 8px -5px 20px 0px lightgrey;
}
button {
display: inline-block;
}
<div class="wrap">
<button>Button 1</button>
<button>Button 2</button>
<button>Button 3</button>
<button>Button 4</button>
<button>Button 5</button>
<button>Button 6</button>
</div>
解决方案
尝试这个:
.wrap {
display: flex;
overflow-x: scroll;
}
推荐阅读
- javascript - D3v6 获取g元素位置
- kubernetes - 使用网络策略将命名空间中的 pod 与其他命名空间隔离
- excel - 通过条件格式着色的单元格的 VBA
- ios - Ionic 4 IOS平台无需打开短信app即可发送短信
- c# - 尝试在 c# diffrenet 项目中删除循环依赖
- c# - 形成多维笛卡尔积数组
- export-to-csv - DVC - 进行预定的 csv 转储
- python - 无法使用请求继续解析下一页的名称
- javascript - 是否可以使用 resizeObserver (或类似的东西)来观察元素的顶部/左侧位置?
- php - Json 资源中的 Laravel 集合