【发布时间】:2023-03-12 20:01:01
【问题描述】:
我的一个页面上并排放置了两张全宽图像。它们完美地工作,除了它们没有在底部对齐(你会看到右图比左图略高)。有没有办法解决这个问题?
html
<div class="food-featured-posts">
<div class="food-featured-posts-first">
<?php query_posts( 'p=185'); while (have_posts()): the_post(); ?>
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div></div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part( 'share-buttons' ); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div></div>
<?php endwhile; ?>
<div class="food-featured-posts-second">
<?php query_posts( 'p=173'); while (have_posts()): the_post(); ?>
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div></div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part( 'share-buttons' ); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div></div>
<?php endwhile; ?>
</div>
css
.food-featured-posts-first img {
width: 100%;
height:auto;
}
.food-featured-posts-second img {
width: 100%;
height:auto;
}
.food-featured-posts-first {
width: 50%;
}
.food-featured-posts-second {
width: 50%;
}
.food-featured-posts {
display: flex;
margin-bottom: 200px;
margin-top:125px;
}
用 img 标签代替 - https://jsfiddle.net/v90pug4o/4/
【问题讨论】:
-
您的 html 包含无法在代码 sn-p 中运行的 php 代码
-
您也可以使用
inline-block将它们并排排列,它们将在底部对齐。
标签: html css image image-resizing image-size