我正在尝试设置帖子标题和帖子摘录,以使其与特色图片旁边的日期对齐,但我只能设置日期,但不能设置标题和其他。

这是我的日期CSS,它是一个简单的浮点数:

.post-thumbnail {
  width: 24%;
  float: left;
  margin-right: 20px;
}


的HTML

<div class="post-meta group">
        <p class="post-category"><?php the_category(' / '); ?></p>
        <p class="post-date"><?php the_time('j M, Y'); ?></p>
    </div><!--/.post-meta-->

    <h2 class="post-title">
        <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    </h2><!--/.post-title-->

    <?php if (ot_get_option('excerpt-length') != '0'): ?>
    <div class="entry excerpt">
        <?php the_excerpt(); ?>
    </div><!--/.entry-->
    <?php endif; ?>


当我在类float: left中添加.post-meta时,它将移动标题和摘录,但未在post meta下对齐。

这是我的新www.gazetbits.com。任何指南都将不胜感激,或者将标题和帖子归为一组,将其分组为Div并应用浮动元素是正确的。

谢谢

最佳答案

.post-meta的高度太大。添加此规则,实现了您想要的行为:

.post-meta {
    height: 22px;
}


或更改显示类型:

.post-meta {
    display: table;
}

关于html - CSS设置文章摘录和标题 float 在特色图片旁边,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26097430/

10-12 12:37
查看更多