Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap - Why: Row remove margin-left & not Row-fluid

Row : margin-left: -20px;

Row-fluid : nothing about margin-left.

Why row-fluid is not removing this margin-left by a certain % ?

Edit :
.row-fluid > .span is adding margin-left.

like image 207
Slake Avatar asked Mar 28 '13 08:03

Slake


People also ask

Why do bootstrap rows have negative margin?

Rows have a negative left/right margin of -15px. The Container padding of 15px is used to counteract the negative margins of the Row. This is to keep content evenly aligned on the edges of the layout. If you don't put a Row in a Container, the Row will overflow it's container, causing an undesirable horizontal scroll.

How do I set the margin-left in bootstrap?

l - sets margin-left or padding-left. r - sets margin-right or padding-right. x - sets both padding-left and padding-right or margin-left and margin-right. y - sets both padding-top and padding-bottom or margin-top and margin-bottom.

How do I remove left and right margins in bootstrap?

So the answer is: . container-fluid > . row -- make the margin:0 on the left and right if you remove the padding on the left and right of the column classes.

Why margin-right is not working on table?

margin-right will not work if you set width to 100%. What you could do is : wrap table in a div tag.


2 Answers

You can find out more about the fluid aspects of Bootstrap here: http://twitter.github.com/bootstrap/scaffolding.html#fluidGridSystem

It's because <span> tags ecapsulated within .row have a margin-left: 20px. The negative left margin is to counter this so that the row displays correctly. With the .row-fluid > span relationship, span tags within that encapsulation don't have a left margin therefore this doesn't need to be corrected within .row-fluid

like image 195
Luke Smith Avatar answered Oct 18 '22 03:10

Luke Smith


That's hard to explain, your answer is in bold, the rest is context.

What's the logic when in static layout?

The span elements have margin-left: 20px to stay separated from other spans.

The row element has margin-left: -20px to ensure that the first span -or any span placed at the "left column"- is placed at the begining of the container.

It works because the static row has not set its width, so that margin-left: -20px does not substract width to the element, that continues filling its ancestor.

What happens in a fluid layout?

We could try the same logic, but the difference is that the width and margin-left of span elements is defined in percents, so if we increase the actual width of the row element (by applying a negative margin), these span elements also increase its size, so they don't fit within the container.

So fluid layout uses a different technique for achieving a similar result, just applies a margin-left: 0 to the :first-child.

Digging deeper

And why not use the same strategy in both layouts? Sure, that will simplify the implementation, but the static technique (that is not applicable to fluid) is more powerful. That's because any element that falls in the "left column", being :first-child or not, will became "margin-corrected". Static layouts need that kind of behaviour to comfortably providing responsiveness, fluid layouts can -more or less- manage without it.

like image 32
albertedevigo Avatar answered Oct 18 '22 02:10

albertedevigo