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条)

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动