网站元素在不设置高度时,可以根据内容自动撑开,通过鼠标滑轮可以滚动,但是反过来横向显示内容时,通过鼠标滑轮无法滚动,必须点击滚动条才能实现横向滚动。代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
box-sizing: border-box
}
html,
body {
height: 100%;
margin: 0;
padding: 0
}
.wrap {
width: 4000px;
height: 100%
}
.wrap .m {
width: 200px;
height: 200px;
margin-top: 200px;
display: inline-block;
margin-right: 10px;
background: blue
}
</style>
</head>
<body>
<div class="wrap">
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
<div class="m"></div>
</div>
</body>
</html>
因为body有默认宽度,所以设置wrap宽度为4000px,怎样才能通过滑轮就可以实现滚动,无需点击下方滚动条,是不是必须通过js实现。