如何使用css将内容与页面中心对齐

时间:2013-12-04 04:28:44

标签: html css

我正在使用以下代码在页面末尾添加文字

@media print
{
    .page:after
    {
        content: "copyrighted data";
        color: #e7792e;
        font-size: 14px;
        position: fixed;
        bottom: 0;
    }
}

如何将上述内容与页面中心对齐?

4 个答案:

答案 0 :(得分:1)

这会有用吗?

.page:after {
    content: "copyrighted data";
    color: #e7792e;
    font-size: 14px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
}

答案 1 :(得分:0)

只需添加

text-align: center;

到你的css

@media print
{
    .page:after
    {
        content: "copyrighted data";
        color: #e7792e;
        font-size: 14px;
        position: fixed;
        bottom: 0;
        text-align: center;
    }
}

答案 2 :(得分:0)

这会有用吗?这应该集中在您想要添加背景的类中放置的所有内容。

@media print
{
    .page:after
    {
        content: "copyrighted data";
        text-align:center;
        margin: 0 auto;
        color: #e7792e;
        font-size: 14px;
        position: fixed;
        bottom: 0;
    }
}

答案 3 :(得分:0)

尝试在你的风格中加入“margin:0 auto”。