【问题标题】:Wordpress sidebar positioningWordPress侧边栏定位
【发布时间】:2013-09-22 06:01:58
【问题描述】:

我有一个侧边栏,我想将其放在内容的左侧。我已经尝试了所有我能想到的方法,但无法在页面左侧显示侧边栏。

    <div class="container">
        <header>

        </header>
    <?php if ( is_active_sidebar( 'primary' ) )  {?>
 <div class='cats'>
    <?php dynamic_sidebar( 'primary' );  } ?>
  </div>
        <div class='content_wrapper'>
        <?php if ( have_posts() ) : ?>
        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

        <div class="posts">
            <article>
               <div class="wrapper">
               <h2 class='headline'><a href="<?php the_permalink() ?>"></h2>

                <div class='thumbs'>

                <p><?php echo content('120'); ?></p>
            </article>
            //.....
                    // some code
               </div>
            </div>
         ... some more code

【问题讨论】:

    标签: html css wordpress stylesheet


    【解决方案1】:
    Please Put this after header, so you can have sidebar at left
    
    <?php get_sidebar(); ?>
    

    对于动态侧边栏使用这个 css

    .container
    {
        margin:auto!important;
    }
    .cats
    {
        float:left;
        width:30%;
    }
    .content_wrapper
    {
        float:right;
        width:68%;
    }
    

    【讨论】:

    • 我正在使用动态侧边栏,所以我使用 行来显示侧边栏,你不认为我需要一些 CSS 来更改侧边栏位置?
    • 请提供您的网站链接,我会帮助您
    • 您想在左侧显示类别部分吗?
    • 我无法让它向左或向右移动,但我更喜欢它在左侧
    • 请尝试我在回答中提到的 css