Zurb foundation margin between 2 columns

ぃ、小莉子 提交于 2019-12-23 01:49:08

问题


I am trying to put a padding/margin of 10 px between 2 columns. But when I do then the 2nd column breaks.

html code

<div class="row collapse">
   <div class="large-6 medium-6 small-12 columns">Content 1</div>
   <div class="large-6 medium-6 small-12 columns">Content 2</div>
</div>

If I remove collapse then column adds padding to it's all direction. How can I make the row full width but only 10px padding or margin between 2 columns.

Any help is highly appreciated. Thanks in advance.


回答1:


We can't add margins to columns or the row would overflow, because the columns directly touch each other already.

You could try something like this:

<div class="row collapse">
   <div class="large-6 medium-6 small-12 columns space">Content 1</div>
   <div class="large-6 medium-6 small-12 columns space">Content 2</div>
</div>

and then CSS:

.space{
  padding: 10px; 
}

or you could use inner container for columns like this:

<div class="row collapse">
   <div class="large-6 medium-6 small-12 columns">
     <div class="panel">Content 1</div>
    </div>
   <div class="large-6 medium-6 small-12 columns">Content 2</div>
</div>

and then style the panel class




回答2:


This can be accomplished without using custom css by nesting grids. Can be done with collapsed or uncollapsed columns.

<div class="section-container">
<div class="row uncollapse section-wrapper">
 <div class="columns small-6 section-column-wrapper">
   <div class="row collapse">
    <div class="columns small-12">
        Left Column Text
    </div>
   </div>
  </div>
<div class="columns small-6">
  <div class="row collapse section-column-wrapper">
      <div class="columns small-12">
           Right Column Text
      </div>
     </div>
   </div>
  </div>

https://codepen.io/michaelwebster/pen/KXerOx



来源:https://stackoverflow.com/questions/30318275/zurb-foundation-margin-between-2-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!