【发布时间】:2014-02-16 18:30:56
【问题描述】:
我在我的网站上的 wordpress 页面上使用 css 列来显示其子页面中的一些内容。 我所有的页面标题都显示在 2 列中,按字母顺序排列。
像这样:
第 1 列 |第 2 栏
页面标题 A |页面标题 F
页面标题 B |页面标题 G
页面标题 C |页面标题 H
页面标题 D |页面标题我
页面标题 E |页面标题 J
这是我的 html 和 php:
<div class="column_artists_menu">
<?php
$args = array(
'post_type' => 'page',
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'title',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
</div>
和我的 CSS :
.column_artists_menu{
-moz-column-width: 50%;
-webkit-column-width: 50%;
-o-column-width: 50%;
column-width: 50%;
-moz-column-count: 2;
-webkit-column-count: 2;
-o-column-count: 2;
column-count: 2;
-moz-column-gap: 20px;
-webkit-column-gap: 20px;
-o-column-gap: 20px;
column-gap: 20px;
-webkit-column-rule-width: 1px;
-webkit-column-rule-color: #eeeeee;
-webkit-column-rule-style: solid;
-moz-column-rule-width: 1px;
-moz-column-rule-color: #eeeeee;
-moz-column-rule-style: solid;
-o-column-rule-width: 1px;
-o-column-rule-color: #eeeeee;
-o-column-rule-style: solid;
column-rule-width: 1px;
column-rule-color: #eeeeee;
column-rule-style: solid;
}
完美运行。 但我的页面是从上到下排序的,如上表所示。 我想做的是让我的页面标题像这样从左到右显示。
第 1 列 |第 2 栏
页面标题 A |页面标题 B
页面标题 C |页面标题D
页面标题 E |页面标题 F
页面标题 G |页面标题 H
页面标题 I |页面标题 J
有没有办法做到这一点并使用非常有用的 css 列?
非常感谢您的帮助
【问题讨论】:
-
您有在线示例吗?这应该可行,但听起来您有其他规则干扰。您也可以暂时禁用列宽和边框,看看是否会导致问题,因为所有宽度的总和超过 100%。
-
我不确定列是否是正确的解决方案。为什么不在这里使用简单的 html
table?或者只是spans 换行每隔一个元素?
标签: php css html wordpress multiple-columns