我正在尝试在固定宽度的 div 内水平显示多个 div(框)。我想使用水平滚动条来显示所有不适合父 div 的 div。
但是,div 是垂直显示的,而不是水平显示的。有没有办法强制它们并排显示?并使用水平滚动条查看它们。我已经发布了下面的编码。
<html>
<head>
<title> Slide </title>
<style type="text/css">
.total
{
height:350px;
width:75%;
border:1px solid black;
margin-left:auto;
margin-right:auto;
margin-top:15%;
}
.slidepanel
{
border:1px solid purple;
width:100%;
height:100%;
overflow-x: scroll;
overflow-y: hidden;
}
.slideleft
{
border:1px solid green;
width:5%;
height:10%;
margin-left:5%;
float:left;
text-align:center;
//padding-top:1%;
}
.slideright
{
//padding-top:1%;
border:1px solid green;
width:5%;
height:10%;
margin-left:80%;
float:left;
text-align:center;
}
.box
{
border:1px solid red;
width:100%;
height:100%;
float:left;
margin-left:auto;
margin-right:auto;
}
</style>
</head>
<body>
<div class="total">
<div class="slidepanel">
<button class="slideleft">
<<
</button>
<button class="slideright">
>>
</button>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
</div>
</div>
</body>
</html>