Как заполнить высоту дочерних элементов другой стороной по высоте; - PullRequest
0 голосов
/ 14 мая 2019

Я пытаюсь сделать некоторые блоки с помощью CSS и HTML, немногие из них имеют фиксированную высоту, например, как вы видите 200px, но другие должны быть динамичными / гибкими и должны быть растянуты на другие высоты. Блоки C, G, H должны быть динамическими и растягиваться на максимальные текущие высоты противоположных блоков с содержимым. На рисунке вы видите, что блоки выходят из зоны, блоки C, G, H должны находиться на высоте, где рисуется красная линия;

Представь, что я хочу сказать Image what i want to say

.clearFix {
  clear: both;
}


/*        Header blocks    */

.headerBlockSection {
  color: white;
  font-size: 50px;
}

.block-A {
  width: calc((100% / 4 * 3) - 10px);
  height: 200px;
  background-color: #008000;
  float: left;
  margin-right: 10px;
}

.block-B {
  width: calc(100% / 4 * 1);
  height: 200px;
  background-color: #008000;
  float: left;
}


/*        Main content sections    */

.mainContentSection {
  margin-top: 10px;
  color: white;
  display: flex;
}

.contentSection-1 {
  width: calc((100% / 4 * 1));
  float: left;
  height: auto;
}

.contentSection-2 {
  width: calc((100% / 4 * 2) - 20px);
  float: left;
  margin-left: 10px;
  margin-right: 10px;
}

.contentSection-3 {
  width: calc((100% / 4 * 1));
  float: left;
}


/*        Left    */

.block-C {
  background-color: #f8eb3a;
  height: 100%;
}


/*        Middle    */

.block-D {
  height: 150px;
  background-color: #316266;
}

.block-E {
  margin-top: 10px;
  height: 150px;
  background-color: #316266;
}

.block-G {
  margin-top: 10px;
  background-color: #316266;
  height: 100%;
}


/*
        Right
    */

.block-F {
  height: 150px;
  background-color: #801a00;
}

.block-H {
  margin-top: 10px;
  background-color: #801a00;
  height: 100%;
}


/*        Footer blocks    */

.block-I {
  margin-top: 10px;
  width: 100%;
  height: 200px;
  background-color: #9ad7ff;
}
<body>
  <header class="headerBlockSection">
    <div class="block-A">A</div>
    <div class="block-B">B</div>
    <div class="clearFix"></div>
  </header>

  <section class="mainContentSection">
    <div class="contentSection-1">
      <div class="block-C"> C </div>
    </div>
    <div class="contentSection-2">
      <div class="block-D">D</div>
      <div class="block-E">E</div>
      <div class="block-G"> G </div>
    </div>
    <div class="contentSection-3">
      <div class="block-F">F</div>
      <div class="block-H">H</div>
    </div>
    <div class="clearFix"></div>
  </section>

  <div class="block-I">I</div>

</body>

1 Ответ

0 голосов
/ 14 мая 2019

Вы ищете что-то вроде это ?

.mainContentSection {
  margin-top: 10px;
  color: white;
  display: flex;
  overflow: hidden;   /* I added this value*/
}

Вот полный код.Я также добавил немного текста в раздел G, чтобы прояснить ситуацию.

.clearFix {
  clear: both;
}


/*        Header blocks    */

.headerBlockSection {
  color: white;
  font-size: 50px;
}

.block-A {
  width: calc((100% / 4 * 3) - 10px);
  height: 200px;
  background-color: #008000;
  float: left;
  margin-right: 10px;
}

.block-B {
  width: calc(100% / 4 * 1);
  height: 200px;
  background-color: #008000;
  float: left;
}


/*        Main content sections    */

.mainContentSection {
  margin-top: 10px;
  color: white;
  display: flex;
  overflow: hidden; /* I added this value*/
}

.contentSection-1 {
  width: calc((100% / 4 * 1));
  float: left;
  height: auto;
}

.contentSection-2 {
  width: calc((100% / 4 * 2) - 20px);
  float: left;
  margin-left: 10px;
  margin-right: 10px;
}

.contentSection-3 {
  width: calc((100% / 4 * 1));
  float: left;
}


/*        Left    */

.block-C {
  background-color: #f8eb3a;
  height: 100%;
}


/*        Middle    */

.block-D {
  height: 150px;
  background-color: #316266;
}

.block-E {
  margin-top: 10px;
  height: 150px;
  background-color: #316266;
}

.block-G {
  margin-top: 10px;
  background-color: #316266;
  height: 100%;
}


/*         Right     */

.block-F {
  height: 150px;
  background-color: #801a00;
}

.block-H {
  margin-top: 10px;
  background-color: #801a00;
  height: 100%;
}


/*        Footer blocks    */

.block-I {
  margin-top: 10px;
  width: 100%;
  height: 200px;
  background-color: #9ad7ff;
}
<body>
  <header class="headerBlockSection">
    <div class="block-A">A</div>
    <div class="block-B">B</div>
    <div class="clearFix"></div>
  </header>

  <section class="mainContentSection">
    <div class="contentSection-1">
      <div class="block-C"> C </div>
    </div>
    <div class="contentSection-2">
      <div class="block-D">D</div>
      <div class="block-E">E</div>
      <div class="block-G"> G <br> Lorem ipsum dolor sit amet consectetur adipisicing elit. Numquam, quas ullam ad eveniet ratione maiores fuga sapiente alias repellendus dolor sequi voluptate quaerat aliquam ut totam, perspiciatis cupiditate molestias? Tempora!
      </div>
    </div>
    <div class="contentSection-3">
      <div class="block-F">F</div>
      <div class="block-H">H</div>
    </div>
    <div class="clearFix"></div>
  </section>

  <div class="block-I">I</div>

</body>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...