gpt4 book ai didi

css - 当浏览器视口(viewport)缩小时,如何防止我的列堆叠

转载 作者:行者123 更新时间:2023-11-28 01:21:25 24 4
gpt4 key购买 nike

我不想让我的列在浏览器视口(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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com