Как сделать отзывчивый bootstrap элемент квадратным - PullRequest
0 голосов
/ 24 марта 2020

Я пытаюсь создать страницу для купонов, вот код HTML:

<!-- Content -->
<div class="section section-contents section-pad">
    <div class="container">
        <div class="content row">

            <div class="row row-feature row-column">
                <!-- Coupon Boxes -->
                <div class="col-md-4 col-sm-4">
                    <div class="feature boxed coupon">
                        <div class="fbox-content center">
                             <span class="scissors">
                                <i class="fa fa-scissors"></i>
                             </span>
                            <h2>Residential Plumbing</h2>
                            <p>Lorem ipsum dolor sit amet, conse ctetur adip isicing elit, sed do eius mod tempor incididunt fuga platea ut labore et.</p>
                            <p class="fineprint" >Valid Mon-Sat 7AM-7PM. Cannot be combined with any other offer<br>Offer Expires: <?php echo date("m/d/y",strtotime("last day of +0 month")); ?></p>
                        </div>
                    </div>
                </div>
                <!-- End Coupon box -->

                <!-- Coupon Boxes -->
                <div class="col-md-4 col-sm-4">
                    <div class="feature boxed coupon">
                        <div class="fbox-content center">
                             <span class="scissors">
                                <i class="fa fa-scissors"></i>
                             </span>
                            <h2>Residential Plumbing</h2>
                            <p>Lorem ipsum dolor sit amet, conse ctetur adip isicing elit, sed do eius mod tempor incididunt fuga platea ut labore et.</p>
                            <p class="fineprint" >Valid Mon-Sat 7AM-7PM. Cannot be combined with any other offer<br>Offer Expires: <?php echo date("m/d/y",strtotime("last day of +0 month")); ?></p>
                        </div>
                    </div>
                </div>
                <!-- End Coupon box -->


                <!-- Coupon Boxes -->
                <div class="col-md-4 col-sm-4">
                    <div class="feature boxed coupon">
                        <div class="fbox-content center">
                             <span class="scissors">
                                <i class="fa fa-scissors"></i>
                             </span>
                            <h2>Residential Plumbing</h2>
                            <p>Lorem ipsum dolor sit amet, conse ctetur adip isicing elit, sed do eius mod tempor incididunt fuga platea ut labore et.</p>
                            <p class="fineprint" >Valid Mon-Sat 7AM-7PM. Cannot be combined with any other offer<br>Offer Expires: <?php echo date("m/d/y",strtotime("last day of +0 month")); ?></p>
                        </div>
                    </div>
                </div>
                <!-- End Coupon box -->


            </div>
            <!-- End Feature Boxes -->

        </div>
    </div>
</div>
<!-- End content -->

Вот тот CSS, который я написал:

    .coupon{
        border-style: dashed;
        border-color: black;
        padding: 15px;
        min-height: 350px;
        vertical-align: middle !important;
    }

    .fineprint{
        font-size: 11px;
        vertical-align: bottom;
    }

    .scissors{
        font-size: 48px;
        color: #000;
        vertical-align: top;
    }

Я бы как коробки с пунктирными линиями, чтобы быть квадратным. На настольном компьютере и мобильном телефоне он выглядит красиво, но на планшете он не квадратный. Я хочу, чтобы это был идеальный квадрат независимо от формата. Как я могу это сделать? Заранее спасибо!

1 Ответ

0 голосов
/ 24 марта 2020

Вы можете сложить их на средний, маленький и очень маленький экран. Довольно сложно собрать их в один ряд со всем вашим контентом, не скрывая их.

      .coupon {
        border-style: dashed;
        border-color: black;
        padding: 15px;
        max-height: 320px;
        max-width: 320px;
        overflow: hidden;
        vertical-align: middle !important;
        margin: 10px;
      }

      .fineprint {
        font-size: 11px;
        vertical-align: bottom;
      }

      .scissors {
        font-size: 48px;
        color: #000;
        vertical-align: top;
      }
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Template</title>

    <!-- bootstrap 4.4 -->
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
      integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
      crossorigin="anonymous"
    />
  </head>
  <body>
    <!-- Content -->
    <div class="section section-contents section-pad">
      <div class="container">
        <div class="content row">
          <div class="row row-feature row-column justify-content-between">
            <!-- Coupon Boxes -->
            <div class="col-lg-4 ">
              <div class="feature boxed coupon">
                <div class="fbox-content center">
                  <span class="scissors">
                    <i class="fa fa-scissors"></i>
                  </span>
                  <h2>Residential Plumbing</h2>
                  <p>
                    Lorem ipsum dolor sit amet, conse ctetur adip isicing elit,
                    sed do eius mod tempor incididunt fuga platea ut labore et.
                  </p>
                  <p class="fineprint">
                    Valid Mon-Sat 7AM-7PM. Cannot be combined with any other
                    offer<br />Offer Expires:
                    <?php echo date("m/d/y",strtotime("last day of +0 month")); ?>
                  </p>
                </div>
              </div>
            </div>
            <!-- End Coupon box -->

            <!-- Coupon Boxes -->
            <div class="col-lg-4 ">
              <div class="feature boxed coupon">
                <div class="fbox-content center">
                  <span class="scissors">
                    <i class="fa fa-scissors"></i>
                  </span>
                  <h2>Residential Plumbing</h2>
                  <p>
                    Lorem ipsum dolor sit amet, conse ctetur adip isicing elit,
                    sed do eius mod tempor incididunt fuga platea ut labore et.
                  </p>
                  <p class="fineprint">
                    Valid Mon-Sat 7AM-7PM. Cannot be combined with any other
                    offer<br />Offer Expires:
                    <?php echo date("m/d/y",strtotime("last day of +0 month")); ?>
                  </p>
                </div>
              </div>
            </div>
            <!-- End Coupon box -->

            <!-- Coupon Boxes -->
            <div class="col-lg-4 ">
              <div class="feature boxed coupon">
                <div class="fbox-content center">
                  <span class="scissors">
                    <i class="fa fa-scissors"></i>
                  </span>
                  <h2>Residential Plumbing</h2>
                  <p>
                    Lorem ipsum dolor sit amet, conse ctetur adip isicing elit,
                    sed do eius mod tempor incididunt fuga platea ut labore et.
                  </p>
                  <p class="fineprint">
                    Valid Mon-Sat 7AM-7PM. Cannot be combined with any other
                    offer<br />Offer Expires:
                    <?php echo date("m/d/y",strtotime("last day of +0 month")); ?>
                  </p>
                </div>
              </div>
            </div>
            <!-- End Coupon box -->
          </div>
          <!-- End Feature Boxes -->
        </div>
      </div>
    </div>
    <!-- End content -->

    <!-- Bootstrap js ,popper js and jquery  -->
    <script
      src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
      integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
      crossorigin="anonymous"
    ></script>

    <script
      src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
      integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
      crossorigin="anonymous"
    ></script>
  </body>
</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...