Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove padding for first and last column in row

I have a situation where the grid can't have an outside left and right padding.

How to set padding-left:0; for first column in line and set padding-right:0. This should also when screen changes... Or make similar result.

<div class="row line">
  <div class="large-2 medium-3 small-4 columns"></div>
  <div class="large-2 medium-3 small-4 columns"></div>
  <div class="large-2 medium-3 small-4 columns"></div>
  <div class="large-2 medium-3 small-4 columns"></div>
</div>
  1. line for large screen
  2. line for medium screen
  3. line for small screen

Yellow space should be with no padding, white spaces has default foundation padding.

enter image description here

like image 457
Gediminas Avatar asked Oct 22 '14 11:10

Gediminas


People also ask

How do I get rid of top padding in HTML?

Adjusting the Margin Size of an HTML Element With CSS You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .

How do you stop padding from increasing width?

to fix this, you simply need to update the box-sizing parameter and set this to border-box in your css. Or you can do this for all elements by simply adding the following. This tells the browser to account for any border and padding in the values you specify for an element's width and height.


1 Answers

One way to achieve this would be to target the first and last columns.

.row.line > .columns:first-child {
  padding-left: 0;
}
.row.line > .columns:last-child {
  padding-right: 0;
}

Another option would be to create a class to apply to the first and last columns.

<div class="row line">
  <div class="large-2 medium-3 small-2 columns column-first"></div>
  <div class="large-2 medium-3 small-2 columns"></div>
  <div class="large-2 medium-3 small-2 columns"></div>
  <div class="large-2 medium-3 small-2 columns column-last"></div>
</div>

.column-first {
  padding-left: 0;
}
.column-last {
  padding-right: 0;
}
like image 125
squashriddle Avatar answered Oct 31 '22 01:10

squashriddle