h2标题显示页面内容下方
我一直在修改 WordPress 主题,当我刚刚开始在页面中添加内容时,我注意到 h2 标题显示在内容下方(请参见此处:http://mefo1.ecin1prod1lnx1.com/about/history/)。我似乎找不到解释。
下面是 page.php 代码。我很乐意粘贴可能需要的任何其他代码。
非常感谢你,
亚历克斯
<?php get_header(); ?>
<script>
jQuery(document).ready(function(){
jQuery(".share").click(function(){
jQuery(this).next("div").slideToggle("slow");
jQuery(this).toggleClass("active"); return false;
});
});
</script>
<div class="posts-column">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php include(TEMPLATEPATH . '/includes/share.php'); ?>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="clear"></div>
<?php endwhile ?>
<div class="clear"></div>
<h2 class="page"><?php the_title(); ?></h2>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
<?php endif; ?>
</div><!--end posts-column-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I have been modifying a wordpress theme and as I just began to put content in the pages, I noticed the h2 header is displaying below the content (see here:http://mefo1.ecin1prod1lnx1.com/about/history/). I can't seem to find an explanation.
Below is the page.php code. I am happy to PasteBin any other code that might be needed.
Thank you very much,
Alex
<?php get_header(); ?>
<script>
jQuery(document).ready(function(){
jQuery(".share").click(function(){
jQuery(this).next("div").slideToggle("slow");
jQuery(this).toggleClass("active"); return false;
});
});
</script>
<div class="posts-column">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php include(TEMPLATEPATH . '/includes/share.php'); ?>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="clear"></div>
<?php endwhile ?>
<div class="clear"></div>
<h2 class="page"><?php the_title(); ?></h2>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
<?php endif; ?>
</div><!--end posts-column-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
移至 div 类条目上方
Move above your div class entry
阅读@Shaun 所说的。请记住,div 默认情况下是块元素,这意味着它们会增长以占据所需的空间。这会强制所有同级块从下面开始,除非通过 css 另有指定。将 h2 移至文档顶部。正常的文档流是从左到右,从上到下,因此您的第一个 div (带有“entry”类)将显示为块级元素(因为您没有另外指定),并且它的同级元素将在下面呈现,因此为什么您的 h2元素不在您期望的位置。
Read what @Shaun said. Remember, divs are block elements by default which means they will grow to take up as much room as they need. This forces any sibling blocks to start below unless otherwise specified through css. Move your h2 to the top of the document. Normal document flow is left to right, top to bottom so your first div (with class "entry") will be displayed as a block level element (since you didn't specify otherwise) and it's sibling will be rendered below hence why your h2 element is not where you expect.