简体   繁体   English

将侧边栏与我的主要内容引导程序对齐

[英]Align sidebar with my main content bootstrap

I am using Bootstrap and WordPress to create a website. 我正在使用Bootstrap和WordPress创建网站。 I have a my main content that is 8 columns and then my sidebar which is 4. On my normal pages I put them both in one row so they align correctly, however with this page, I used the WordPress loop to create many rows with content in, this means my sidebar is then not in the same row as my content and gets pushed to below it on the screen. 我的主要内容是8列,然后是侧边栏,它是4。在我的普通页面上,我将它们都放在一行中,以便它们正确对齐,但是在此页面上,我使用WordPress循环创建了许多包含内容的行,这意味着我的侧边栏与内容不在同一行,并被推到屏幕下方。 Is it possible to align them horizontally? 是否可以将它们水平对齐?

Here is the code I'm using. 这是我正在使用的代码。

<?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<div class="row case-studies">
     <div id="page_content">
         <div class="col-md-8">
            <div class="case_summary_image col-md-4">
                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('casestudy img-responsive');?></a>
            </div>
                <div class="case_summary col-md-8"></a>
                    <a style="font-size:18px; line-height:30px; color:#666666; font-weight:bold; text-decoration:none" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

                        <?php the_excerpt(); ?>

                </div>
        </div>
</div>
</div>

<!-- sidebar -->


<?php endwhile; endif; ?>

<div class="col-md-4">
<?php get_sidebar();?>
</div>

您仍然需要一个容器或一行来包含内容和侧栏,以使各列​​按您希望的那样工作。

You must create loop main area and add class to this. 您必须创建循环主区域并向其中添加类。 So, 所以,

<div class="col-md-8">
<!-- your loop, wp query -->
</div>

<div class="col-md-4">
<!-- your theme sidebar -->
</div>

In summary, you must have one col-md-8 and one col-md-4. 总之,您必须具有一个col-md-8和一个col-md-4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM