gpt4 book ai didi

html - 如何在 CSS 中使文本居中并且最大宽度为 800px?

转载 作者:行者123 更新时间:2023-11-28 01:47:02 26 4
gpt4 key购买 nike

我试图将页面上的一段文本居中,同时保持 800 像素的最大宽度。我该怎么做呢?这是我的代码:

#footer {
text-align: center;
height: 200px;
width: 100%;
opacity: 1;
background-color: #47a7d3;
position: absolute;
bottom: 0;
left: 0;
padding: 0;
}

#terms {
width: 800px;
margin-top: 3em;
margin-bottom: -0.75em;
line-height: 1.2em;
font-size: 12px;
font-family: Arial;
color: #ffffff;
}

最佳答案

你可以试试这个

定义你的 #footer id left:0; right:0; 移除 : 100%;

像这样定义你的#terms margin-left: auto; margin-right:auto;

CSS

#footer {
text-align: center;
height: 200px;
opacity: 1;
background-color: #47a7d3;
position: absolute;
bottom: 0;
left:0;
right:0;
padding:0;
}

#terms {
width: 800px;
margin-top: 3em;
margin-bottom: -0.75em;
margin-left:auto;
margin-right:auto;
line-height: 1.2em;
font-size: 12px;
font-family: Arial;
color: #ffffff;
}

Demo

关于html - 如何在 CSS 中使文本居中并且最大宽度为 800px?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22086321/

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