When I do boostrap I have to use the class "row" ...
When you look at my test design:
Why I am forced with a margin-left of -30px?
With this html I would expect 3 rows sharing each column 33% of the whole available width:
<div class="container"> <div class="row"> <div style="background-color: pink;" class="span4"> This is a label </div> <div style="background-color: violet;" class="span4"> This is a textbox </div> <div style="background-color: slateblue;" class="span4"> This is a button </div> </div> <div class="row"> <div style="background-color: orange;" class="span4"> This is a label </div> <div style="background-color: orangered;" class="span4"> This is a textbox </div> <div style="background-color: yellow;" class="span4"> This is a button </div> </div> <div class="row"> <div style="background-color: seagreen;" class="span4"> This is a label </div> <div style="background-color: green;" class="span4"> This is a textbox </div> <div style="background-color: lightgreen;" class="span4"> This is a button </div> </div> </div>
The gray area with the buttons is from this code:
<div style="background-color: gray;"> <div class="pager"> <div class="pull-left"> <a href="#" class="btn" data-bind="css: { disabled: !hasPrevious() }, click: previous">previous</a> <a href="#" class="btn" data-bind="css: { disabled: !hasNext() }, click: next">next</a> </div> <div class="pull-right"> <span data-bind="text: stepNumber()" /> <span>/</span> <span data-bind="text: stepsLength" /> </div> </div> <hr /> <!-- ko compose: { model: activeStep, transition: 'entrance' } --> <!-- /ko --> </div>
Why does the whole 3-column design fall together when I remove the -30px margin-left?
How should I change my code to really get a 3 column layout each column having the same width. This is what span4 should do.
css - Why does the bootstrap . row class have a default margin-left of -30px? - Stack Overflow.
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.
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.
If you need to separate rows in bootstrap, you can simply use . form-group . This adds 15px margin to the bottom of row.
question 1:
the span
s all have a margin-left
of 30px
to create some space between the single blocks. this space should only appear between the single span
s and not at the beginning (or end) of the row
. to accomplish this, there are several possibilitys - for example:
margin
with the space-with on the row (this is what bootstrap does):first-child
selector to remove margin-left on the first span
in a rowi can only assume the bootstrap uses the first option because it's more compatible with older browsers (most likely IE 7 and below).
a little example: lets say your span
s have a width of 100, a space of 10 and there are 3 in a row.
question 2 if you use span4
s, you already have 3 columns of the same width. you don't need to change anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With