Wordpress:在页脚部分创建列

时间:2014-01-12 14:26:58

标签: php html css wordpress

目前我的页脚看起来像这样: enter image description here

我使用以下html:

<div class="mainfooter">
    <!-- 1/2 -->
    <div class="column">
        <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('footer-left-widget') ) ?>
        <h3> Customer Service </h3>
    </div>
    <div class="column">
        <?php if ( !function_exists( 'dynamic_sidebar' ) || !dynamic_sidebar('footer-right-widget') ) ?>
        <h3> Contact Us</h3>
        <div class="fb-like-box" data-href="https://www.facebook.com/pages/LIdylle-Idyll/466829146717006" data-width="30" data-height="60" data-colorscheme="light" data-show-faces="false" data-header="true" data-stream="false" data-show-border="true"></div>
    </div>
    <!-- /End 2/2 -->
</div>

我的css看起来像这样:

.site-footer .mainfooter .column {               
    position: relative; 
    width: 44%; 
    padding: 3%; 
    float: left;                
}               
.site-footer .mainfooter .column:nth-child(1) { left: 50%; }
.site-footer .mainfooter .column:nth-child(2) { right: 50%; }
.site-footer .mainfooter:before .mainfooter:after{
    content: " ";
    position: absolute;
    z-index: -1;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    background: #ccc;    
}

.site-footer .mainfooter:after{
    left: 50%;
    background: #eee;       
}

我查看过以前的评论和帖子同样如下:Two column layout in Wordpress?并尝试了此处提到的所有方法:http://css-tricks.com/fluid-width-equal-height-columns/但我仍然无法解决此问题。

我在functions.php文件中也添加了以下代码:

if (function_exists('register_sidebar')) {
    register_sidebar(array(
        'name' => 'Footer Left',
        'id'   => 'footer-left-widget',
        'description'   => 'Left Footer widget position.',
        'before_widget' => '<div id="%1$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>'
    ));

    register_sidebar(array(
        'name' => 'Footer Right',
        'id'   => 'footer-right-widget',
        'description'   => 'Right Footer widget position.',
        'before_widget' => '<div id="%1$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h2>',
        'after_title'   => '</h2>'
    ));

我正在尝试创建两列,每列下面都有内容,但我无法正常工作。

1 个答案:

答案 0 :(得分:0)

CSS中的大部分代码都不是必需的。您需要为右侧和左侧面板创建一个规则,如下所示:

.column {
    display: inline-block;
    width: 44%;
    padding: 3%
}

.column-left {
    float: left;
}

.column-right {
    float: right;
    clear: right;
}

并在两列中添加一个包装器标签:

.row {
    display: inline-block;
    clear: left;
    width: 100%;
}

请查看此fiddle