2
我正在使用Flexboxes創建以頁面爲中心的內容。但是,如果文本溢出,我希望它有一個滾動條使用overflow-x: auto
。停止彈出對齊項從打破溢出自動
很明顯,這不起作用,我一直在頭撞我的桌子一陣子。我必須在這裏錯過簡單的東西,但我不能爲了我的生活而弄清楚這一點。
在代碼片段中,第一個盒子是我真正喜歡的第二個盒子,除了Flexbox打破它。
.flex-container{
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 20px;
}
.scrollable-content{
overflow-x: auto;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<div class="scrollable-content">
<div style="background-color: red;width: 700px;height: 50px">I might be too wide on small screens, but you have a scrollbar if I am!</div>
</div>
<div class="flex-container">
<div class="scrollable-content">
<div style="background-color: red;width: 700px;height: 50px">I might be too wide on small screens, but you have a scrollbar if I am!</div>
</div>
</div>
</body>
</html>
我知道這是簡單的東西!謝謝! – Pharylon