doqau82086 2018-06-18 18:01
浏览 102
已采纳

使用语义网格在响应列中显示自定义分类术语

I am using a WP theme that includes the semantic grid.

For example, if I want to create 3 responsive columns I can use the following markup in a post or page:

<div class="grid-33">
Column 1
</div>
<div class="grid-33">
Column 2
</div>
<div class="grid-33">
Column 3
</div>

I am using php to grab and display a list of term links from a custom taxonomy I am using with Woocommerce. It works nicely to create a list. The problem is that the list is very long.

The echo section of the php is as follows:

echo "<h1 class='vendor-title'>MY TITLE</h1>"; 
        echo "<p class='vendor-subtext'>My subtext.</p>";
        echo "<ul class='vendor-list'>";
        foreach ( $terms as $term ) {
            echo '<li><a href="' . get_term_link( $term ) .'">' . $term->name . '</a></li>';
        }
        echo "</ul>";

What I want to do is to format the PHP so that the resulting list is displayed in 3 responsive columns using semantic grid-33 class divs.

How can I code this?

  • 写回答

2条回答 默认 最新

  • douzai2562 2018-06-19 17:13
    关注

    I found a better solution for this. You can use column-count and column-gap css instead to style the list.

    You can change the column count using @media break points to have less columns on tablet and phone view.

    For example:

    .vendor-list {
        -moz-column-count: 4;
        -moz-column-gap: 10px;
        -webkit-column-count: 4;
        -webkit-column-gap: 10px;
        -ms-column-count:4;
        -ms-column-gap:10px;
        column-count: 4;
        column-gap: 10px;
    }
    
    @media (max-width: 768px) {
        .vendor-list {    
        -moz-column-count: 2;
        -moz-column-gap: 5px;
        -webkit-column-count: 2;
        -webkit-column-gap: 5px;
        -ms-column-count:2;
        -ms-column-gap:5px;
        column-count: 2;
        column-gap: 5px;
    }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决