Исправлен контент начальной загрузки - PullRequest
0 голосов
/ 19 мая 2018

Работа над адаптивным шаблоном с помощью начальной загрузки и попытка создать что-то вроде enter image description here

Я вижу, что bg может быть .container-fluid, но содержимое выровнено container.Как это может быть сделано?Теперь у меня есть эта структура

<div class="services">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12 col-md-4 services-black">
                <h1>SEO Optimized</h1>
                <p>
                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
                </p>
            </div>
            <div class="col-12 col-md-4 services-red">
                <h1>Responsive</h1>
                <p>
                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
                </p>
            </div>
            <div class="col-12 col-md-4 services-green">
                <h1>Cloud Services</h1>
                <p>
                    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
                </p>
            </div>
        </div>
    </div>
</div>

, и теперь текст растягивается на всю ширину контейнера.Нужен ли мне вложенный контейнер, такой как

<div class="container-fluid">
    <div class="container">
        ..
    </div>
</div>

или что-то еще?как правильно это реализовать?

Ответы [ 2 ]

0 голосов
/ 19 мая 2018

Вы можете вкладывать .container после .container-fluid, а также можете использовать класс .services или .container-fluid, чтобы получить background-color, и для того, чтобы использовать цвета фона в качестве примера, я использовал псевдоэлемент для .services класс

.services:before {
  position: absolute;
  left: 0;
  top: 0;
  background-color: black;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

.services:after {
  position: absolute;
  right: 0;
  top: 0;
  background-color: green;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

 /* you can also give the styles to the .container-fluid*/
.services {
  position: relative;
  color: white;
}

.services:before {
  position: absolute;
  left: 0;
  top: 0;
  background-color: black;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

.services:after {
  position: absolute;
  right: 0;
  top: 0;
  background-color: green;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}


.services-black {
  background-color: black;
}

.services-red {
  background-color: red;
}

.services-green{
  background-color: green;
}
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
        
         <div class="services">
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-12 col-md-4 services-black">
<h1>SEO Optimized</h1>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
</p>
</div>
<div class="col-12 col-md-4 services-red">
<h1>Responsive</h1>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
</p>
</div>
<div class="col-12 col-md-4 services-green">
<h1>Cloud Services</h1>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
</p>
</div>
</div>
</div>
</div>
</div>
0 голосов
/ 19 мая 2018

Gradient Way

Вы можете назначить background:linear-gradient(to right,black,black,green,green), чтобы получить желаемый фон.И container как класс на вашем контенте.

.services {
  background: linear-gradient(to right, black, black, green, green);
}

.services-red {
  background: red;
  color: white;
}

.services-green {
  background: green;
  color: white;
}

.services-black {
  background: black;
  color: white;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="services">
  <div class="container">
    <div class="row">
      <div class="col-12 col-md-4 services-black">
        <h1>SEO Optimized</h1>
        <p>
          Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        </p>
      </div>
      <div class="col-12 col-md-4 services-red">
        <h1>Responsive</h1>
        <p>
          Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        </p>
      </div>
      <div class="col-12 col-md-4 services-green">
        <h1>Cloud Services</h1>
        <p>
          Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
        </p>
      </div>
    </div>
  </div>
</div>

Bootstrap + Flex Way

Как достичь ожидаемого пространства:

  1. Получить другое<div> внутри вашего services-*
  2. Приведите ширину согласно вашему удобству.
  3. На вашем контейнере, т. Е. services-*, укажите следующие свойства

    .services-black{
      display:flex;
      justify-content:flex-end; // Align box to right
    }
    .services-green{
      display:flex;
      justify-content:flex-start;  //Align box to left
    }
    .services-red{
      display:flex;
      justify-content:center;    //Align box to center
    }
    

.cloud,
.seo,
.responsive {
  width: 60%;
}

.services-black {
  background: black;
  color: white;
  display: flex;
  justify-content: flex-end;
}

.services-green {
  background: green;
  color: white;
  display: flex;
  justify-content: flex-start;
}

.services-red {
  background: red;
  color: white;
  display: flex;
  justify-content: center;
}

@media (max-width: 768px) {
  .cloud,
  .seo,
  .responsive {
    width: 100%;
  }
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<div class="services">
  <div class="container-fluid">
    <div class="row">
      <div class="col-12 col-md-4 services-black">
        <div class="seo">
          <h4>SEO Optimized</h4>
          <p>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
          </p>
        </div>
      </div>
      <div class="col-12 col-md-4 services-red">
        <div class="responsive">
          <h4>Responsive</h4>
          <p>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
          </p>
        </div>

      </div>
      <div class="col-12 col-md-4 services-green">
        <div class="cloud">
          <h4>Cloud Services</h4>
          <p>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
          </p>
        </div>

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