Проблема возникла, когда min-width: 768px выравнивание изображения и содержимого текста!

По сути, я хочу сохранить изображение и текст по очереди, один за другим, в мобильной компоновке, и одно изображение и связанный текст должны быть выровнены по горизонтали друг за другом в макете планшета, но это разбивка! Настольный компьютер в порядке!

Вот код

.sq-about-main {
  margin-bottom: 80px;
}

.s-about-col-areas {
  display: block;
  margin: 10% auto;
  overflow: hidden;
}

.s-about-col-areas:after {
  content: "";
  clear: both;
  display: block;
}

.s-about-col {
  width: 100%;
  float: left;
  position: relative;
  padding-bottom: 100%;
}

@media (min-width: 768px) {
  .s-about-col {
    width: calc(100% / 2);
    padding-bottom: calc(100% / 2);
  }
}

@media (min-width: 1200px) {
  .s-about-col {
    width: calc(100% / 4);
    float: left;
    position: relative;
    padding-bottom: calc(100% / 4);
  }
}

.s-about-col .s-about-col-content {
  width: calc(100%);
  height: calc(100%);
  /*margin: 8px;*/
  /*padding: 16px;*/
  position: absolute;
  border-radius: 2px;
  background-color: #ffffff;
  /*box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);*/
}

.image-col .s-about-col-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
}

.s-about-col-content i {
  position: absolute;
  left: 45px;
  bottom: 45px;
  font-size: 20px;
  line-height: 20px;
  color: #646464;
  border: 1px solid #646464;
  padding: 10px;
  cursor: pointer;
}

.text-col {
  display: table;
}

.text-col .text-col-content {
  padding: 30% 45px 45px 45px;
  height: 100%;
  display: table-cell;
  text-align: left;
  vertical-align: middle;
}

.text-col .text-col-content h2 {
  font-family: "Helvetica-Bold", sans-serif;
}

.text-col .text-col-content p {
  font-family: "Roboto", sans-serif;
  font-size: 20px;
  color: #656565;
}

.text-col .text-col-content.l-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -25px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 25px solid transparent;
  border-bottom: 25px solid transparent;
  border-right: 25px solid #ffffff;
  z-index: 2;
}

.text-col .text-col-content.r-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  right: -25px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 25px solid transparent;
  border-bottom: 25px solid transparent;
  border-left: 25px solid #ffffff;
  z-index: 2;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />



<div class="sq-about-main">
  <div class="container-fluid px-5-percent">

    <div class="s-about-col-areas">
      <div class="s-about-col image-col">
        <div class="s-about-col-content">
          <img src="https://i.imgur.com/3U2Fd7P.jpg" alt="">
        </div>
      </div>
      <div class="s-about-col text-col">
        <div class="s-about-col-content text-col-content l-arrow">
          <h2>Who We are</h2>
          <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
          </p>

          <i class="el-icon-plus"></i>

        </div>
      </div>
      <div class="s-about-col image-col">
        <div class="s-about-col-content">
          <img src="https://i.imgur.com/jXTai9N.jpg" alt="">

        </div>
      </div>
      <div class="s-about-col text-col">
        <div class="s-about-col-content text-col-content l-arrow">
          <h2>Mission & Vision</h2>
          <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
          </p>

          <i class="el-icon-plus"></i>

        </div>
      </div>
    </div>
    <div class="s-about-col-areas">

      <div class="s-about-col text-col">
        <div class="s-about-col-content text-col-content r-arrow">
          <h2>Philosophy</h2>
          <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
          </p>
          <i class="el-icon-plus"></i>

        </div>
      </div>
      <div class="s-about-col image-col">
        <div class="s-about-col-content">
          <img class="" src="https://i.imgur.com/pZdZJvq.jpg" alt="">
        </div>
      </div>
      <div class="s-about-col text-col">
        <div class="s-about-col-content text-col-content r-arrow">
          <h2>Achievements</h2>
          <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
          </p>
          <i class="el-icon-plus"></i>

        </div>
      </div>
      <div class="s-about-col image-col">
        <div class="s-about-col-content">
          <img class="m-0" src="https://i.imgur.com/tJVEprD.jpg" alt="">

        </div>
      </div>
    </div>
  </div>

</div>
0
Momin

2 ответа

Пожалуйста, поместите этот код в свой CSS.

@media (max-width: 767px) {
.s-about-col{padding-bottom: 0;}
.s-about-col .s-about-col-content{position: relative;}
}

Я бы переосмыслил структуру, так как ваши 8 коробок - это в основном 4 коробки с 2 частями в каждой. Затем вы можете управлять последовательностью с помощью float влево / вправо, например так:

.sq-about-main {
  margin-bottom: 80px;
}

.s-about-col-areas {
  display: block;
  margin: 10% auto;
  overflow: hidden;
}

.s-about-col-areas:after {
  content: "";
  clear: both;
  display: block;
}

.s-about-col {
  width: 100%;
  position: relative;
  padding-bottom: 100%;
}
.floatleft .s-about-col {
  float:left;
}
 
.floatright .s-about-col {
  float:right;
}

@media (min-width: 768px) {
  .s-about-col {
    width: calc(100% / 2);
    padding-bottom: calc(100% / 2);
  }
}

@media (min-width: 1200px) {
  .s-about-col {
    width: calc(100% / 4);
    float: left;
    position: relative;
    padding-bottom: calc(100% / 4);
  }
}

.s-about-col .s-about-col-content {
  width: calc(100%);
  height: calc(100%);
  /*margin: 8px;*/
  /*padding: 16px;*/
  position: absolute;
  border-radius: 2px;
  background-color: #ffffff;
  /*box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);*/
}

.image-col .s-about-col-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
}

.s-about-col-content i {
  position: absolute;
  left: 45px;
  bottom: 45px;
  font-size: 20px;
  line-height: 20px;
  color: #646464;
  border: 1px solid #646464;
  padding: 10px;
  cursor: pointer;
}

.text-col {
  display: table;
}

.text-col .text-col-content {
  padding: 30% 45px 45px 45px;
  height: 100%;
  display: table-cell;
  text-align: left;
  vertical-align: middle;
}

.text-col .text-col-content h2 {
  font-family: "Helvetica-Bold", sans-serif;
}

.text-col .text-col-content p {
  font-family: "Roboto", sans-serif;
  font-size: 20px;
  color: #656565;
}

.text-col .text-col-content.l-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -25px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 25px solid transparent;
  border-bottom: 25px solid transparent;
  border-right: 25px solid #ffffff;
  z-index: 2;
}

.text-col .text-col-content.r-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  right: -25px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 25px solid transparent;
  border-bottom: 25px solid transparent;
  border-left: 25px solid #ffffff;
  z-index: 2;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />

<div class="sq-about-main">
<div class="container-fluid px-5-percent">

    <div class="s-about-col-areas">
        <div class="element floatleft">
            <div class="s-about-col image-col">
                <div class="s-about-col-content">
                    <img src="https://i.imgur.com/3U2Fd7P.jpg" alt="">
                </div>
            </div>
            <div class="s-about-col text-col">
                <div class="s-about-col-content text-col-content l-arrow">
                    <h2>Who We are</h2>
                    <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
                    </p>

                    <i class="el-icon-plus"></i>

                </div>
            </div>
        </div>
        <div class="element floatleft">
            <div class="s-about-col image-col">
                <div class="s-about-col-content">
                    <img src="https://i.imgur.com/jXTai9N.jpg" alt="">

                </div>
            </div>
            <div class="s-about-col text-col">
                <div class="s-about-col-content text-col-content l-arrow">
                    <h2>Mission & Vision</h2>
                    <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
                    </p>

                    <i class="el-icon-plus"></i>

                </div>
            </div>
        </div>
    </div>
    <div class="s-about-col-areas">
        <div class="element floatright">
            <div class="s-about-col image-col">
                <div class="s-about-col-content">
                    <img class="" src="https://i.imgur.com/pZdZJvq.jpg" alt="">
                </div>
            </div>
            <div class="s-about-col text-col">
                <div class="s-about-col-content text-col-content r-arrow">
                    <h2>Philosophy</h2>
                    <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
                    </p>
                    <i class="el-icon-plus"></i>

                </div>
            </div>
        </div>
        <div class="element floatright">
            <div class="s-about-col image-col">
                <div class="s-about-col-content">
                    <img class="m-0" src="https://i.imgur.com/tJVEprD.jpg" alt="">

                </div>
            </div>
            <div class="s-about-col text-col">
                <div class="s-about-col-content text-col-content r-arrow">
                    <h2>Achievements</h2>
                    <p>We strive to go above and beyond for our clients, fostering a relationship built on trust, confidence
                    </p>
                    <i class="el-icon-plus"></i>

                </div>
            </div>
        </div>
    </div>
</div>

</div>
58502861