wordpress侧边栏引导定位

时间:2013-11-12 01:24:13

标签: wordpress twitter-bootstrap position sidebar

基本上,我做了 - 2个引导跨度为8和4.我将侧边栏代码放入正确的一个(4个跨度),但由于某种原因,它显示了侧边栏下面的内容,位于span8。

<div class="row pull-right" id="pgg">
<div class="span8" id="pagecn">
    <?php the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <div class="entry-content">
        <div class="ttl">
        <?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><a title="<?php printf( __('Read %s', 'blankslate'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?>
        </div>
<div id="cn">
<?php the_content(); ?>
</div>
     </div>
 </div>
<div class="span4">
<?php if ( is_active_sidebar('primary-widget-area') ) : ?>
<div id="primary" class="widget-area">
<ul class="sid">
<?php dynamic_sidebar('primary-widget-area'); ?>
</ul>
</div>
<?php endif; ?>
 </div>
</div>

和css代表那段代码

#pgg {
width:948px;
margin-top:4px;
background-color: white;
padding-top: 10px;
padding-bottom: 20px;
}

#cn {margin-top: 15px;}

2 个答案:

答案 0 :(得分:0)

如果您不小心向列中添加了一些填充或边距,或者更改了列或其父级的默认宽度,通常会发生这种情况。如果没有发生,请检查代码检查器。此外,查看您的代码将有助于解决问题。

P.S。你是否意识到你正在使用一个旧的,不再开发的Bootstrap版本?当前版本是3.0.2。你可以从中大大地使用它。

答案 1 :(得分:0)

您忘记关闭<div>,更准确地说div.span8可能就是为什么它不正确。

<div class="row pull-right" id="pgg">
    <div class="span8" id="pagecn">
        <?php the_post(); ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

            <div class="entry-content">
                <div class="ttl">
                    <?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><a title="<?php printf( __('Read %s', 'blankslate'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?>
                </div> <!-- /.ttl -->
                <div id="cn">
                    <?php the_content(); ?>
                </div> <!-- /#cn -->
            </div> <!-- /.entry-content -->
        </div> <!-- /#post-<?php the_ID(); ?> -->
    </div> <!-- /.span8 (you forgot this one) -->

    <div class="span4">
        <?php if ( is_active_sidebar('primary-widget-area') ) : ?>
        <div id="primary" class="widget-area">
            <ul class="sid">
                <?php dynamic_sidebar('primary-widget-area'); ?>
            </ul>
        </div>
        <?php endif; ?>
    </div>
</div>

另一件事,默认情况下.row类有width: 940px;如果我是你我不会弄乱默认宽度除非你自定义网格