【发布时间】:2015-07-16 07:55:57
【问题描述】:
以下代码...
<article id="post-<?php the_ID(); ?>" style="background-image:url('<?php echo $thumbnail_url ?>')" <?php post_class('container-fluid'); ?> >
<div class="container-fluid text-cell">
<div class="col-md-12 textr">
<h2><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_category(', '); ?>
</div>
</div>
</article><!-- /#post -->
... 为我的 Wordpress 主题创建帖子。它用标题、类别和背景图像组成一行(100% 宽度)。每个帖子都堆叠在一起。
我希望标题和类别留在文章的底部(我在 div 上放置了一个 'textr' 类,以便将它们组合在一起。
然而,这个 div 现在位于它应该在的文章的顶部,而不是内部和底部
css
article {
background-repeat: no-repeat;
background-size: cover;
border-top: 1px solid #000;
background-position: left center;
height: 400px;
margin: 0;
padding: 0;
}
.text-cell {
position: relative;
margin: 0;
padding: 0;
}
.textr{
position: absolute;
left: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
}
【问题讨论】:
标签: html css wordpress css-position absolute