Html 在div中添加容器并不是将容器与中心对齐,而且如何在保持其初始大小的同时获得滚动效果
它似乎有一些空白右推集装箱到左边,但我希望它保持在中心。 同样对于滚动,我需要将高度设置为100 vh以获得滚动效果,但它修改了我不想要的容器高度 相反,我希望它有如下容器 CSS代码Html 在div中添加容器并不是将容器与中心对齐,而且如何在保持其初始大小的同时获得滚动效果,html,css,Html,Css,它似乎有一些空白右推集装箱到左边,但我希望它保持在中心。 同样对于滚动,我需要将高度设置为100 vh以获得滚动效果,但它修改了我不想要的容器高度 相反,我希望它有如下容器 CSS代码 .home { display: flex; flex-direction: column; justify-content: center; align-items: center; } .container { background: black; bord
.home {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.container {
background: black;
border-radius: 15px;
margin: 20px;
padding: 15px;
text-align: center;
color: white;
width: 80%;
height: 80%;
}
.listing {
height: 50vh;
width: 100%;
overflow-y: scroll;
}
.listing::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.listing {
-ms-overflow-style: none;
/* IE and Edge */
scrollbar-width: none;
/* Firefox */
}
HTML代码
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Menu </title>
<link rel="stylesheet" href="./style.css">
<!-- <link rel="stylesheet" href="./fontawesome-free-5.13.0-web/css/all.css"> -->
</head>
<body>
<div class="home">
<div class="container">
<h1>SOMETHING</h1>
</div>
<div class="listing">
<div class="container">
<!-- <h2>Experience</h3> -->
<h3>TSOMETHING</h3>
<div>
<div>SOMETHING</div>
<div> Something</div>
</div>
<div> SOMETHING <br> SOMETHING </div>
</div>
<div class="container">
<!-- <h2>Experience</h3> -->
<h3>TSOMETHING</h3>
<div>
<div>SOMETHING</div>
<div> Something</div>
</div>
<div> SOMETHING <br> SOMETHING </div>
</div>
<div class="container">
<!-- <h2>Experience</h3> -->
<h3>TSOMETHING</h3>
<div>
<div>SOMETHING</div>
<div> Something</div>
</div>
<div> SOMETHING <br> SOMETHING </div>
</div>
<div class="container">
<!-- <h2>Experience</h3> -->
<h3>TSOMETHING</h3>
<div>
<div>SOMETHING</div>
<div> Something</div>
</div>
<div> SOMETHING <br> SOMETHING </div>
</div>
<div class="container">
<!-- <h2>Experience</h3> -->
<h3>TSOMETHING</h3>
<div>
<div>SOMETHING</div>
<div> Something</div>
</div>
<div> SOMETHING <br> SOMETHING </div>
</div>
</div>
</div>
</body>
</html>
菜单
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
某物
将.container
的边距更改为边距:20px自动代码>从页边距:20px代码>
谢谢你的保证金自动修复未对齐。我还想知道如何降低集装箱内箱子的高度,而不是100vh?它太大了,所以我希望它更像列表之外的标题container@Justastudent为.container
指定高度:适合内容代码>