中心我的网站在html

Centering my site in html

本文关键字:html 网站 我的      更新时间:2023-09-26

我想知道我是否可以做一些类似于这个网站(http://www.viralnova.com/hasnt-bathed-60-years-gallery/?mb=sk&Skyid=815)。这个网站有一个背景,然后在背景之上是一堆内容。当您前后滑动页面时,除非将页面滑动到最左边,否则内容将保持居中。在这一点上,页面停止调整,只是停留在左边。我想知道是否有什么东西可以把这种效果放在我的网站上。我应该把我的网站内容放在一个特定的div里,然后让这个div居中吗?

如果我的问题让你感到困惑,我很抱歉。-谢谢

你可以像下面这样包装你的内容

<div class="wraper">
    <div class="content"></div>
</div>

设置包装器的宽度,marginauto分别位于包装器的左右

.wraper {
    display:block;
    width:200px; <-- define a width
    height: 100px;
    margin: 10px auto; <-- set margin left and right to auto
    background: yellow;
}
演示