Я начинаю использовать Bourbon Neat от Thoughtbot для адаптивных сеток. В целом, это довольно гладко, и мне это очень нравится, но я зациклился на одной маленькой проблеме.
Я пытаюсь заставить две колонки соприкасаться друг с другом без полей, но после попытки воспроизвести то, что у них есть, из их примеров, я не получаю того же результата.
Вот пример HTML:
<section>
<p>
This is the main section.
</p>
<div class="container">
<p>
This is the container
</p>
<div class="col1">
<p>
This is the 1st column.
</p>
</div>
<div class="col2">
<p>
This is the 2nd column.
</p>
</div>
</div>
</section>
Вот мой СКСС:
section {
@include outer-container;
text-align: center;
}
.container {
@include span-columns (12);
text-align: center;
margin: 0;
padding: 0;
.col1 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
}
.col2 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
}
}
Что производит это:
Но когда я пытаюсь заставить два столбца вкладываться/соприкасаться друг с другом, используя табличный метод, как показывает их пример, я получаю следующее:
SCSS:
section {
@include outer-container;
text-align: center;
}
.container {
@include span-columns (12);
@include row (table);
text-align: center;
margin: 0;
padding: 0;
.col1 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
}
.col2 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
@include reset-display;
}
}
Вывод:
Если я иду по маршруту @include omega();
, который работает, но тогда он не расширяет полную ширину последнего столбца:
SCSS:
section {
@include outer-container;
text-align: center;
}
.container {
@include span-columns (12);
text-align: center;
margin: 0;
padding: 0;
.col1 {
@include span-columns(6);
@include omega();
background: #ccc;
@include pad(em(15));
}
.col2 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
@include omega();
}
}
Вывод:
По сути, я мог бы просто опустить содержимое, находящееся в разделе контейнера, что дает результат, который я ищу. Но нужно ли для этого создавать пустой div
?:
SCSS
section {
@include outer-container;
text-align: center;
}
.container {
@include span-columns (12);
@include row(table);
text-align: center;
margin: 0;
padding: 0;
.col1 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
}
.col2 {
@include span-columns(6);
background: #ccc;
@include pad(em(15));
@include reset-display
}
}
HTML (содержимое в .container
закомментировано):
<section>
<p>
This is the main section.
</p>
<div class="container">
<!-- <p>
This is the container
</p> -->
<div class="col1">
<p>
This is the 1st column.
</p>
</div>
<div class="col2">
<p>
This is the 2nd column.
</p>
</div>
</div>
</section>
Вывод:
В любом случае, я не знаю, какой "правильный" способ добиться этого. Документация на самом деле не является конкретной для объяснения того, как сделать так, чтобы два столбца вкладывались друг в друга. И то, что я пытался воспроизвести на их примере, не дало того же результата.
Если мне не нужно специально добавлять margin:0;
в последний столбец.