dongsiju1941 2015-11-13 17:22
浏览 40

无法按照我想要的方式对齐列表元素

I have a list of post titles with their featured image above it. The last post title in the list is two lines, so it messes up the alignment of the list. Below is an image. I want the first three posts to move upwards to align with the last one.

enter image description here

The code:

<div class="classes-links">
  <?php 
    $args = array(
      'post_type' => 'class',
      'posts_per_page' => 4,
      'order' => 'ASC'
    );

    $query = new WP_Query($args);
  ?>

  <?php while ($query->have_posts()) : $query->the_post(); ?>
    <a href="<?php the_permalink(); ?>">
      <ul><li><?php the_post_thumbnail(); ?></li>
          <li><?php the_title(); ?></li>
      </ul>
    </a>
  <?php endwhile; wp_reset_query(); ?>
</div>

CSS:

.classes-services .classes-div .classes-links {
  display: inline-block;
  float: right;
  position: relative;
  margin: 80px 250px 0 0;
}

.classes-services .classes-div .classes-links a {
  text-decoration: none;
  color: #113337;
}

.classes-services .classes-div .classes-links ul {
  display: inline-block;
  margin: 0 auto;
  text-align: center;
}
  • 写回答

2条回答 默认 最新

  • dongtaijiao7140 2015-11-13 17:27
    关注

    You could put them in a table and set valign:top; on the tr element. If you use percentage based width for the table and the td elements, it will flex fine if your application is responsive.

    This will align the images to the top instead of middle aligning the text and image.

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能