【发布时间】:2016-12-13 19:18:55
【问题描述】:
注意:在这篇文章的底部,我刚刚添加了一个更新。更新中的 cmets 可能会使原始帖子的某些部分变得多余。 最终,我想在我的所有页面上都有一个评论部分。目前我只是在某些页面上激活了 cmets。
我没有在这个页面上激活 cmets http://www.rosstheexplorer.com/how-to-back-up-photos-when-abroad/
我确实在此页面上激活了 cmets http://www.rosstheexplorer.com/blue-moutnains-and-katoomba-nsw/
当我激活 cmets 时,FB 插件会从屏幕右侧移动到页面底部。我怎样才能防止这种情况?我改变了评论区的宽度,让评论区向左浮动,但这并没有解决我的问题。我还删除了“clear:both”文本,但这并没有解决问题。我现在已将“clear:both”文本放回我的代码中。
当没有 cmets 时,小部件区域位于站点内容内。
当有 cmets 时,小部件区域会移动。我怎样才能防止这种情况?这是造成问题的原因吗?
有人有什么建议吗?
评论区号是
`/* =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 代码是
<?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(); ?>
cmets.php 代码是
<?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 “%2$s”', '%1$s thoughts on “%2$s”', 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 的底部
<?php get_sidebar(); ?>
</div><!-- #primary -->
<?php get_footer(); ?>
然后我在 IE 开发者工具中的评论区搞乱了。很明显,评论区是侧边栏或/和小部件区域的一部分。当我将评论区域的宽度更改为 200 像素时,它移动到了内容的右侧,而不是其下方。
然后使用 IE 开发工具,我移动了评论区域,使其嵌套在内容区域中。然后评论区和FB插件都出现了我希望它们出现的样子。
如何更改我的代码以使评论区永久嵌套在内容区中?
【问题讨论】:
-
这似乎不是 css 问题,似乎一个插件(可能)正在改变内容块的呈现方式。可以禁用所有插件,用cmets看一下帖子,看看是否一切正常?
-
我禁用了所有插件,除了一些关键的插件,如 Akismet,不幸的是它没有任何影响:(
-
这些图片是如何添加的?你能用一些虚拟文本在另一个测试帖子上激活 cmets 并链接它吗?
标签: php css wordpress widget comments