Displaying dynamically created lists in different columns

后端 未结 3 714
礼貌的吻别
礼貌的吻别 2021-01-28 13:09

I have some list of vendors in my site, those vendors list are created manually.

Live Site

Those links are displaying in one single column div

相关标签:
3条回答
  • 2021-01-28 13:38

    you can use CSS columns, like this:

    .vendor-list {
      -webkit-columns: 3;  /* Chrome, Safari, Opera */
      -moz-columns: 3;  /* Firefox */
      columns: 3;
    }
    @media (max-width: 640px) {
      .vendor-list {
        -webkit-columns: 1;    /* Chrome, Safari, Opera */
        -moz-columns: 1;    /* Firefox */
        columns: 1;
      }
    }
    <div class="rte">
      <ul class="vendor-list block-grid three-up mobile one-up">
        <li class="vendor-list-item" style="font-size: 20px;">
          <a href="/collections/accessorizeus-com">accessorizeus.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/betseyjohnson-com">Betseyjohnson.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/bladeandblue-com">bladeandblue.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/chicnova-com">chicnova.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/choies-com">choies.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/footnotesonline-com">footnotesonline.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/forzieri-com">forzieri.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/frenchconnection-com">frenchconnection.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/gaiam-com">gaiam.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/johnstonmurphy-com">Johnstonmurphy.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/kelsidaggerbk-com">kelsidaggerbk.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/lanebryant-com">lanebryant.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/mattandnat-com">mattandnat.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/maykool-com">maykool.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/monicavinader-com">Monicavinader.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/moosejaw-com">moosejaw.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/onlineshoes-com">onlineShoes.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/pinkqueen-com">pinkqueen.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/rebeccataylor-com">rebeccataylor.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/romwe-com">romwe.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/ronherman-com">ronherman.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/rosewe-com">rosewe.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/rotita-com">rotita.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/shabbyapple-com">shabbyapple.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/shein-com">sheIn.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/shoes-com">Shoes.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/swimspot-com">swimspot.com</a>
        </li>
        <li class="vendor-list-item" style="font-size:20px">
          <a href="/collections/toddsnyder-com">Toddsnyder.com</a>
        </li>
      </ul>
    </div>

    0 讨论(0)
  • 2021-01-28 14:01

    Add display property:

    .vendor-list-item {
      display: inline-block;
      width: 33%;
    }
    

    For mobile, use media queries:

    @media (max-width: 480px){
      .vendor-list-item {
         width: 100%;
         text-align: center;
       }
    }
    

    You could also add a condition for tablets (<767px) to show in 2 columns (width: 50%).

    Info about media queries: https://developer.mozilla.org/es/docs/CSS/Media_queries

    Results

    0 讨论(0)
  • 2021-01-28 14:02

    Try to add:

    .vendor-list-item {
        width: 33%;
        float: left;
    }
    
    0 讨论(0)
提交回复
热议问题