首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将注释区移动到内容区

将注释区移动到内容区
EN

Stack Overflow用户
提问于 2016-08-08 13:46:52
回答 3查看 440关注 0票数 2

注意:在这篇文章的底部,我刚刚添加了一个更新。更新中的评论可能会使原始帖子的某些部分变得多余。最终,我想在我所有的页面上都有一个评论区。目前,我只是在一些页面上激活了评论。

我没有在此页面上激活评论http://www.rosstheexplorer.com/how-to-back-up-photos-when-abroad/

我确实在此页面上激活了评论http://www.rosstheexplorer.com/blue-moutnains-and-katoomba-nsw/

当我激活注释时,FB插件从屏幕的右侧移动到页面的底部。我如何防止这种情况发生?我改变了评论区的宽度,让评论区向左浮动,但这并没有解决我的问题。我也去掉了"clear:both“文本,这并没有解决问题。我现在已经将"clear:both“文本放回了我的代码中。

当没有评论时,小部件区域在site-content内。

当有注释时,小部件区域就会移动。我如何防止这种情况发生?这是导致问题的原因吗?

有人有什么建议吗?

备注区号是

代码语言:javascript
复制
`/* =Comments */

.comments-area {
margin: 24px auto 0;
border-top: 3px solid #eee;
}

.comments-title,
#respond h3 {
font-size: 1.2em;
line-height: 1.36em;
color: #999;
}
.comments-title small,
.comment-reply-title small {
float: right;
}

.comment-list,
.comment-list .children {
list-style: none;
}

.comment-list {
margin: 0;
}

.comment-list > .comment:first-of-type {
padding-top: 0;
border-top: 0;
}

.comment {
margin-top: 26px;
padding-top: 27px;
border-top: 1px solid #eee;
}

.comment-meta {
text-transform: uppercase;
}
.comment-meta a {
color: #666;
}
.comment-meta .comment-author img {
float: left;
border-radius: 50%;
}
.comment-meta .comment-author .fn {
display: block;
font-weight: normal;
margin-left: 74px;
text-transform: none;
}
.bypostauthor > article .fn:after {
content: "\f304";
font-size: 16px;
left: 3px;
position: relative;
top: -5px;
}
.comment-meta .comment-metadata {
font-size: .8125em;
font-weight: normal;
line-height: 2.09231em;
margin-bottom: 27px;
margin-left: 74px;
letter-spacing: 1px;
color: #999;
}
.comment-meta .comment-metadata a {
color: #999;
}
.comment-meta .comment-metadata a:hover {
color: #1c7c7c;
}

.comments-area .edit-link:before {
display: inline;
margin: 0 7px;
content: ' ~ ';
}

.comment-form label {
display: inline-block;
width: 109px;
}

.required {
color: #1c7c7c;
}

.comment-form-author,
.comment-form-email,
.comment-form-url,
.comment-form-comment {
position: relative;
margin: 0 0 27px;
}
.comment-form-author label,
.comment-form-email label,
.comment-form-url label,
.comment-form-comment label {
font-size: .8125em;
font-weight: normal;
line-height: 2.09231em;
position: absolute;
top: 7px;
left: 0;
padding: 7px 14px;
letter-spacing: 1px;
text-transform: uppercase;
}
.comment-form-author input,
.comment-form-email input,
.comment-form-url input,
.comment-form-comment input {
display: block;
clear: both;
width: 100%;
margin: 0 0 27px;
padding-left: 100px;
}
.comment-form-author textarea,
.comment-form-email textarea,
.comment-form-url textarea,
.comment-form-comment textarea {

width: 100%;
margin: 0 0 27px;
padding: 54px 14px 7px;
}

.says {
display: none;
}

.form-allowed-tags {
color: #999;
}

.no-comments {
font-style: italic;
margin: 27px 0;
text-align: center;
color: #999;
}

index.php代码是

代码语言:javascript
复制
<?php
/**
 * The main template file.

 *
 *
 * @package Penscratch
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">



        <?php if ( have_posts() ) : ?>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php
                    /* Include the Post-Format-specific template for the content.
                     * If you want to override this in a child theme, then include a file
                     * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                     */
                    get_template_part( 'content', get_post_format() );
                ?>

            <?php endwhile; ?>

            <?php penscratch_paging_nav(); ?>

        <?php else : ?>

            <?php get_template_part( 'content', 'none' ); ?>

        <?php endif; ?>

        </main><!-- #main -->
    </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

comments.php代码是

代码语言:javascript
复制
<?php
/**
 * The template for displaying Comments.
 *
 * The area of the page that contains both current comments
 * and the comment form.
 *
 * @package Penscratch
 */

/*
 * If the current post is protected by a password and
 * the visitor has not yet entered the password we will
 * return early without loading the comments.
 */
if ( post_password_required() ) {
    return;
}
?>

<div id="comments" class="comments-area">



    <?php // You can start editing here -- including this comment! ?>

    <?php if ( have_comments() ) : ?>
        <h2 class="comments-title">
            <?php
                printf( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'penscratch' ),
                    number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
            ?>
        </h2>

        <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
        <nav id="comment-nav-above" class="comment-navigation" role="navigation">
            <h1 class="screen-reader-text"><?php _e( 'Comment navigation', 'penscratch' ); ?></h1>
            <div class="nav-previous"><?php previous_comments_link( __( '< Older Comments', 'penscratch' ) ); ?></div>
            <div class="nav-next"><?php next_comments_link( __( 'Newer Comments >', 'penscratch' ) ); ?></div>
        </nav><!-- #comment-nav-above -->
        <?php endif; // check for comment navigation ?>

        <ol class="comment-list">
            <?php
                wp_list_comments( array(
                    'style'       => 'ol',
                    'short_ping'  => true,
                    'avatar_size' => 60
                ) );
            ?>
        </ol><!-- .comment-list -->

        <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?>
        <nav id="comment-nav-below" class="comment-navigation" role="navigation">
            <h1 class="screen-reader-text"><?php _e( 'Comment navigation', 'penscratch' ); ?></h1>
            <div class="nav-previous"><?php previous_comments_link( __( '< Older Comments', 'penscratch' ) ); ?></div>
            <div class="nav-next"><?php next_comments_link( __( 'Newer Comments >', 'penscratch' ) ); ?></div>
        </nav><!-- #comment-nav-below -->
        <?php endif; // check for comment navigation ?>

    <?php endif; // have_comments() ?>

    <?php
        // If comments are closed and there are comments, let's leave a little note, shall we?
        if ( ! comments_open() && '0' != get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
    ?>
        <p class="no-comments"><?php _e( 'Comments are closed.', 'penscratch' ); ?></p>
    <?php endif; ?>

    <?php comment_form(); ?>



</div><!-- #comments -->

更新-我更改了索引.php的底部

代码语言:javascript
复制
<?php get_sidebar(); ?>

</div><!-- #primary -->

<?php get_footer(); ?>

然后我在IE开发人员工具中摆弄了一下评论区。很明显,评论区域是侧栏或/和小部件区域的一部分。当我将评论区的宽度改为200px时,评论区移到了内容的右侧,而不是内容的下方。

然后,使用IE开发人员工具,我移动了评论区,使其嵌套在内容区域中。然后评论区和FB插件都以我想要的方式出现了。

我如何修改我的代码,使评论区域永久嵌套在内容区域中?

EN

回答 3

Stack Overflow用户

发布于 2016-08-09 02:14:58

您正在使用的模板的窗口小部件区域设置为注释下方。您可能希望探索小部件区域所在的模板结构,而不是专注于移动注释。

在CSS中,我看到了小部件区域的以下代码:

代码语言:javascript
复制
.site-content .widget-area {
    margin-top: 27px;
    padding-top: 24px;
    border-top: 3px solid #eee;
}
@media screen and (min-width: 50em) {
    .site-content .widget-area {
        float: right;
        overflow: hidden;
        width: 28%;
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
}

你说过:

然后评论区和FB插件都出现了我希望它们出现的样子。

你有你想要的屏幕截图吗?这肯定会有助于找到一种变通办法。

票数 0
EN

Stack Overflow用户

发布于 2016-08-09 14:16:28

我发现蓝山页面使用的是page.php模板文件,而不是index.php文件。

然后,经过大量实验,我将page.php模板文件的底部修改为以下内容,从而使其正常工作

在修改之前,sidebar.php在主div之外,而与注释相关的代码在主div内。

修改后的代码如下所示

代码语言:javascript
复制
<?php get_sidebar(); ?>

</div><!-- #primary -->

<?php
                    // If comments are open or we have at least one comment, load up the comment template
                    if ( comments_open() || '0' != get_comments_number() ) :
                        comments_template();
                    endif;
                ?>



<?php get_footer(); ?>
票数 0
EN

Stack Overflow用户

发布于 2016-08-11 14:54:38

我修改了你发布的代码。我添加了结束标记,并将注释代码移到了它上面,这就是您需要将其放置在与主div相同的宽度的位置。

此外,get_sidebar还渲染了一个辅助div,它需要与主div并排放置,以便它能浮动在它旁边。我使用firebug修改了代码,并附上了一个屏幕截图,以澄清这就是你要找的。

代码语言:javascript
复制
<?php

if ( comments_open() || '0' != get_comments_number() ) :
 comments_template();
 endif;
?>

  </main>

</div><!-- #primary -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38822025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档