gpt4 book ai didi

html - 让文本在所有屏幕尺寸下都停留在页面的中间/中心?

转载 作者:太空宇宙 更新时间:2023-11-03 19:57:43 25 4
gpt4 key购买 nike

我试图让我的页眉停留在页面的中间,不管我在什么窗口大小。

我试过使用 Bootstrap。

<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<h1 class=" section-title ">StackOverflow</h1>
</div>
</div>

还有这个 CSS。

.section-title {
margin-left:auto;
margin-right;auto;
}

然后,一旦我缩小窗口,我的标题就会继续回到左边。我该如何阻止呢?最好的方法是什么?

My Fiddle is here - 如果你需要的话。

最佳答案

您应该将 ; 替换为 :。也到死点:

html, body {height: 100%; width: 100%;}
h1 {text-align: center; display: inline-block; vertical-align: middle;}
.center {position: absolute; top: 0; left: 0; right: 0; left: 0; text-align: center; border: 1px solid #ccc; height: 100%; width: 100%; vertical-align: middle;}
<div class="center">
<h1>Centered</h1>
</div>

关于html - 让文本在所有屏幕尺寸下都停留在页面的中间/中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30786288/

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