为什么我的文字没有居中? (通过WordPress网站)

时间:2013-01-12 20:29:07

标签: wordpress text alignment footer

我一直在研究我的第一个WordPress网站(耶!)我正在使用新的2012主题。没有选项可以将小部件放在页脚中,所以我添加了一个侧边栏,我的文本随机被推到一边。网站:http://www.rachelsilberman.com/dan-krokos/

如果您在Chrome中查看它是居中的,但会缩小页面并缩小到右侧。我把文本放在一个名为footer-name的div中。我觉得有一个漂浮:离开那里发生的事情,或者覆盖了页脚风格的东西。

我正在使用的CSS

footer[role="contentinfo"] {
border-top: 1px solid #ededed;
clear: both;
font-size: 12px;
font-size: 0.857142857rem;
line-height: 2;
max-width: 960px;
max-width: 68.571428571rem;
margin-top: 24px;
margin-top: 1.714285714rem;
margin-left: auto;
margin-right: auto;
padding: 24px 0;
padding: 1.714285714rem 0;
background-color: #E3E3E3;
}
footer[role="contentinfo"] a {
color: #686868;
}
footer[role="contentinfo"] a:hover {
color: #55abe8;
}

#footer-name{
 display: block;
 margin-left: auto;
 margin-right: auto;
 background-color: aqua;
}

#footer-sidebar {
 display:block;
 height: 30px;
}

#footer-sidebar1 {
  width: 300px;
  margin-left: auto;
  margin-right: auto;
}

页脚我将div包裹起来(通过footer.php)

<div id="footer-name">
        <a href="<?php echo esc_url( __( 'http://rachelsilberman.com/', 'twentytwelve' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>"><?php printf( __( 'Website created by %s', 'twentytwelve' ), 'Rachel Silberman' ); ?></a>
        </div>

以及我用来在functions.php。

中创建额外侧边栏的代码
register_sidebar( array(
    'name' => __( 'Footer', 'twentytwelve' ),
    'id' => 'sidebar-2',
    'description' => __( 'Appears on footer', 'twentytwelve' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
) );

1 个答案:

答案 0 :(得分:0)

如果你想让页脚文本居中,你可以试试这个

div#footer-name {
    background-color: aqua;
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center; // added this line
}