Bootstrap 4 Flexbox с фиксированной и гибкой шириной столбцов

Используя Bootstrap 4 и Flexbox, как бы вы выполнили макет с двумя столбцами с фиксированной шириной левого столбца и гибкой правой колонкой?

Я ничего не вижу в документах о том, как этого добиться... Я мог бы сделать это достаточно легко, используя ванильный CSS, но я чувствую, что должен использовать Bootstrap, так как я уже втянул его.


person user1960364    schedule 26.05.2017    source источник


Ответы (2)


Это то, что вы ищите:

HTML-код ---->>

 <div class="main-container">
  <div class="left">
  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 a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
  <div class="right">
  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 a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
</div>

CSS------->>

.main-container{
  display:flex;
  flex-direction:row;
}

.left{

  min-width:200px;
  max-width:200px;
}

Также ссылка Codepen.

person Sidharth Anil    schedule 27.05.2017
comment
Это не реализует Bootstrap, как было запрошено. - person isherwood; 30.01.2020

Что-то вроде этого?

#sticky-sidebar {
  position:fixed;
  max-width: 20%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div class="col-xs-12" id="sticky-sidebar">
        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 a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
      </div>
    </div>
    <div class="col-xs-8" id="main">
      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 a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </div>
</div

person Gerard    schedule 26.05.2017
comment
Не липкая боковая панель, а колонка с фиксированной и гибкой шириной. например. Левый столбец имеет размер 200 пикселей, правый столбец занимает 100% оставшейся ширины контейнера. Отсюда и желание использовать Flexbox. - person user1960364; 27.05.2017
comment
Это не работает. Левый столбец не сохраняет свою ширину при изменении размера браузера. - person Mark; 06.06.2017