作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不想让我的列在浏览器视口(viewport)缩小时堆叠,我希望这些列保持原样,但会出现一个水平滚动条,这样使用较小设备的用户只需向右滑动即可滚动。
这可能吗,因为我使用的是 flex?
body {
color: #333;
font-family: Helvetica Neue,Arial,Helvetica,sans-serif;
font-size: 14px;
line-height: 20px;
font-weight: 400;
}
.board-container {
background-color: rgb(0, 121, 191);
height: 100%;
position: relative;
background-size: cover;
overflow: hidden;
}
#board-surface {
display: flex;
flex-direction: column;
}
#board-surface, body, html {
height: 100%;
}
#content {
flex-grow: 1;
overflow-y: auto;
outline: none;
}
.board-wrapper {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.board-main-content {
height: 100%;
display: flex;
flex-direction: column;
margin-right: 0;
transition: margin .1s ease-in;
}
.board-canvas {
position: relative;
flex-grow: 1;
}
/*#board {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
margin-bottom: 8px;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 8px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}*/
.list-wrapper {
width: 272px;
margin: 0 4px;
height: 100%;
box-sizing: border-box;
display: inline-block;
vertical-align: top;
white-space: nowrap;
background-color: #cccccc;
}
.list {
background: #e2e4e6;
border-radius: 3px;
box-sizing: border-box;
display: flex;
flex-direction: column;
max-height: 100%;
position: relative;
white-space: normal;
}
.list-card {
background-color: #fff;
border-radius: 3px;
box-shadow: 0 1px 0 #ccc;
cursor: pointer;
display: block;
margin-bottom: 8px;
max-width: 300px;
min-height: 20px;
position: relative;
text-decoration: none;
z-index: 0;
}
<html>
<head>
<title></title>
</head>
<body>
<div class="board-container">
<div class="board-inner">
<div id="board-surface">
<div id="header">
main header goes here
</div>
<div id="content">
<div class="board-wrapper">
<div class="board-main-content">
<div class="board-header">board header</div>
<div class="board-canvas">
<div id="board">
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
</div> <!-- /board-->
</div>
</div>
</div>
</div>
<div id="footer">
</div>
</div>
</div>
</div>
</body>
</html>
最佳答案
演示:https://codepen.io/anon/pen/wxJGMx?editors=0110
我能够在 flex 容器上实现水平滚动。我已将最小宽度赋予 .list-wrapper 并将以下样式添加到 #board item:
.list-wrapper {
min-width: 272px;
width: 272px;
margin: 0 4px;
height: 100%;
box-sizing: border-box;
display: inline-block;
vertical-align: top;
white-space: nowrap;
background-color: #cccccc;
}
#board {
display: flex;
overflow: scroll;
}
关于css - 当浏览器视口(viewport)缩小时,如何防止我的列堆叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51467721/
我有一个具有可变数量子元素的固定大小的 div。我不知道 children 的大小。目标是缩小它们以适合父级。 例子: .parent { width: 100px; height: 100p
我是一名优秀的程序员,十分优秀!