gpt4 book ai didi

html - 滚动条可见,但不起作用

转载 作者:行者123 更新时间:2023-11-28 02:19:15 25 4
gpt4 key购买 nike

非常简单的页面,而且麻烦...我只想水平滚动表格。滚动条是可见的,仅此而已。浏览器的滚动条只能滚动整个页面。如果我将 body 设置为 overflow:hidden 则根本没有滚动条。我是 html 和 css 的新手。我想我已经尝试了我在网上找到的所有建议...:-\

* {
box-sizing: border-box;
}
.row::before,
.row::after {
content:"";
display: table ;
clear: both;
}
body {
background-color: #ebebeb;
font-family: "Open Sans", sans-serif;
margin: 0;
}
.header {
text-align: center;
min-height: 60px;
background-color: #575757;
color: #fff;
line-height: 60px;
}
.header h1 {
margin-top: 0;
}
.rwd-table {
max-width: 899px;
width: 899px;
height: 100%;
overflow-x: scroll;
background-color: aqua;
}
<!DOCTYPE html>
<html>

<body>
<div class="header">
<h1>Title</h1>
</div>
<div class="rwd-table">
<table class="table">
<thead>
<tr>
<th>Godzina</th>
<th>Śr, 10.01</th>
<th>Czw, 11.01</th>
<th>Pt, 12.01</th>
<th>So, 13.01</th>
<th>Nd, 14.01</th>
<th>Pn, 15.01</th>
<th>Wt, 16.01</th>
</tr>
</thead>
<tbody>
<tr>
<td>7.00</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

最佳答案

首先为您的表格制作display:block然后将 overflow-x:auto 设置为您的表格而不是 div,滚动将显示为自动

* {
box-sizing: border-box;
}
.row::before,
.row::after {
content:"";
display: table ;
clear: both;
}
body {
background-color: #ebebeb;
font-family: "Open Sans", sans-serif;
margin: 0;
}
.header {
text-align: center;
min-height: 60px;
background-color: #575757;
color: #fff;
line-height: 60px;
}
.header h1 {
margin-top: 0;
}
.rwd-table {
height: 100%;
background-color: aqua;
}
table {
display: block;
overflow-x: auto;
white-space: nowrap;
}
<!DOCTYPE html>
<html>

<body>
<div class="header">
<h1>Title</h1>
</div>
<div class="rwd-table">
<table class="table">
<thead>
<tr>
<th>Godzina</th>
<th>Śr, 10.01</th>
<th>Czw, 11.01</th>
<th>Pt, 12.01</th>
<th>So, 13.01</th>
<th>Nd, 14.01</th>
<th>Pn, 15.01</th>
<th>Wt, 16.01</th>
</tr>
</thead>
<tbody>
<tr>
<td>7.00</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

关于html - 滚动条可见,但不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48309641/

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