php - Wordpress:在页 footer 分创建列

标签 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>'
    ));

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

最佳答案

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

关于php - Wordpress:在页 footer 分创建列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21075795/

相关文章:

php - 选择最近 7 天添加的数据

php 短标签在 os x 中不起作用

javascript - 在 PHP 中包含 jquery 脚本,带有 php 变量

css - 为什么字体很棒的图标显示空方 block ?

java - 使用 PHP 解压缩使用 Java Android 压缩和上传的文件

php - 如何在 Symfony 和 Doctrine 中实现 ManyToMany 和 OneToMany?

html - 将 child 置于比自身更窄的 parent 中

html - 如何在没有固定高度的情况下将条形图条附加到底部

jquery - 试图默认隐藏我的下拉菜单

html - 如何在 CSS 中创建双底边框