how to make div to next row by using script?

i use slide swiper to display 12 product.

as you can see in the code the slide displayed in one row
so i wanna make it two rows and each row display two products so
as a result, one slide show 4 products by using 2 rows.

but here is problem, i use site which manage site
in there i can bring the products img and information using some specific code
like this ->
so now my coding look like second coding.

so i have to make some script to make 1row in each slide to 2 rows
any help will be so appreciated ! thanks!

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Swiper demo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">

  <!-- Link Swiper's CSS -->
  <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">

  <!-- Demo styles -->
  <style>
    body,
    html {
      padding: 0;
      margin: 0;
      position: relative;
      height: 100%;
    }

    .swiper-container {
      width: 100%;
      height: 100%;
    }

    .swiper-slide {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      position: relative;
    }

    .swiper-slide img {
      display: block;
      width: 100%;
    }

    @media only screen and (min-width: 769px) {
      .swiper-slide:first-child {
        transition: transform 100ms;
      }

      .swiper-slide:first-child img {
        transition: box-shadow 500ms;
      }

      .swiper-slide.swiper-slide-active:first-child {
        transform: translateX(50%);
        z-index: 2;
      }

      .swiper-slide.swiper-slide-active:first-child img {
        box-shadow: 0px 32px 80px rgba(0, 0, 0, 0.35);
      }

      .swiper-slide:nth-child(2) {
        transition: transform 100ms;
      }

      .swiper-slide.swiper-slide-next:nth-child(2) {
        transform: translateX(55%);
        z-index: 1;
      }

      .swiper-container[dir=rtl] .swiper-slide.swiper-slide-active:first-child {
        transform: translateX(-50%);
      }

      .swiper-container[dir=rtl] .swiper-slide.swiper-slide-next:nth-child(2) {
        transform: translateX(-55%);
      }
    }
  </style>
</head>

<body>
  <!-- Swiper -->
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-001.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-002.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-003.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-004.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-005.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-006.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-007.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-008.jpg"></div>
      <div class="swiper-slide"><img src="//cdn.magloft.com/github/swipehttps://swiperjs.com/demos/images/page-009.jpg"></div>
    </div>
    <div class="swiper-scrollbar"></div>
    <div class="swiper-button-next"></div>
    <div class="swiper-button-prev"></div>
    <div class="swiper-pagination"></div>
  </div>

  <!-- Swiper JS -->
  <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>

  <!-- Initialize Swiper -->
  <script>
    var swiper = new Swiper('.swiper-container', {
      slidesPerView: 1,
      centeredSlides: false,
      slidesPerGroupSkip: 1,
      grabCursor: true,
      keyboard: { enabled: true },
      breakpoints: { 769: { slidesPerView: 2, slidesPerGroup: 2 } },
      scrollbar: { el: '.swiper-scrollbar' },
      navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev' },
      pagination: { el: '.swiper-pagination', clickable: true }
    });
  </script>
</body>

</html>
 <div class="swiper-containertwo">
                <div class="swiper-wrapper" style="margin-bottom:15px !important;">
                        
                    
                            <!--/loop_recmd_product(12)/-->
                                <div class="swiper-slide">
                                    <div>
                                    <a href="<!--/recmd_product@link/-->" class="SMS_Viewlink">
                                        <dt class="thumb"><img src="<!--/recmd_product@mobile_image/-->" class="img" alt="" /></dt>
                                    </a>
                                    </div>
                                    <div class="item-price-wrap">
                                    <!--/if_recmd_product@is_soldout/-->
                                    <div class="item-title">sold out<strike><!--/recmd_product@name(200)/--></strike></div>
                                    <!--/else/-->
                                    <div class="item-title"><!--/recmd_product@name(200)/--></div>
                                    <!--/if_recmd_product@price_consumer(+1)/-->
                                    <span class="item-price"><strike><!--/number/recmd_product@price_consumer/--><span class="won">$</span></strike></span>
                                    <!--/end_if/-->

                                    <!--/if_recmd_product@is_term_discount/-->
                                    <span class="item-price"><strike><!--/number/recmd_product@price_sell/--><span class="won">$</span></strike></span>
                                    <span class="item-price"><!--/number/recmd_product@price_discount/--><span class="won">$</span></span>
                                    <!--/else/-->
                                    <span class="item-price"><!--/if_recmd_product@price_replace/--><font class="item-price"><!--/recmd_product@price_replace/--><!--/else/--><!--/number/recmd_product@price_sell/--><span class="won">$</span><!--/end_if/--></font></span>
                                    <!--/end_if/-->
                                    <!--/end_if/-->
                                </div>
                                <!--/if_recmd_product@subname/-->
                                <div class="etc-info">

                                    <div class="size"><!--/recmd_product@subname(150)/--></div>

                                    <div class="review"><div class="name crema-product-reviews-count" data-product-code="<!--/recmd_product@uid/-->" data-format="리뷰 {{{count}}}" data-hide-if-zero="1"></div></div>
                                </div>
                                <!--/else/-->
                                <div class="review"><div class="name crema-product-reviews-count" data-product-code="<!--/recmd_product@uid/-->" data-format="리뷰 {{{count}}}" data-hide-if-zero="1"></div></div>
                                <!--/end_if/-->
                                <div class="icon-tags">
                                    <!--/if_recmd_product@discount_icon/-->
                                    <span style="padding-right:5px;"><img src="<!--/recmd_product@discount_icon/-->"></span>
                                    <!--/end_if/-->
                                    <!--/if_recmd_product@icons/-->
                                        <!--/recmd_product@icons/-->
                                    <!--/end_if/-->
                                </div>
                                </div>
                                
                          
                            <!--/end_loop/-->
                </div>    
                
        
                
                <div class="swiper-scrollbartwo"></div>

                

              </div>
              
              
              
              
   <!-- Swiper JS -->
   

  <!-- Initialize Swiper -->

  <script>
    var swiper = new Swiper('.swiper-containertwo', {
      slidesPerView: 4,
      spaceBetween: 10,
      slidesPerGroupSkip: 1,
      centeredSlides: false,
      grabCursor: true,
      rows: 2,
      breakpoints: { 769: { slidesPerView: 4, slidesPerGroup: 4,rows: 2 } },
      scrollbar: { el: '.swiper-scrollbartwo' },
    });
  </script>

15 thoughts on “how to make div to next row by using script?”

Leave a Comment