我试图在一个页面上集中一个文本块,同时保持最大的宽度为8px。我该怎么做?这是我的代码:

#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;
}

最佳答案

你可以试试这个
定义您的#footeridleft:0;right:0;移除with:100%;
将您的#termsmargin-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

10-07 19:07
查看更多