I'm trying to use table-cell elements in a grid system that utilizes negative margins on rows to eliminate the left and right gutters on nested grid elements. This works fine on floated and inline-block elements, but elements with display: table
, while respecting the negative left margin, ignore the negative right margin:
Strange, eh? A simple demonstration: http://jsfiddle.net/57FAN/1/
All browsers seem to have implemented this the same way, unfortunately. Any ideas?
P.S. Let's postpone the debate over table-* elements for layout until flex box is standardized.
margin-right will not work if you set width to 100%. What you could do is : wrap table in a div tag.
Syntax. The margin-bottom property is specified as the keyword auto , or a <length> , or a <percentage> . Its value can be positive, zero, or negative.
No. Padding only takes positive values. Negatives are ignored or treated as 0, which would have the same effect: none.
The table doesn't ignore the negative margin, but is only 100% in width and shifted 5px to the left. You would need a "100% + 2*5px" to fill the grey area entirely.
The row doesn't have a width, thus uses the entire width available.
If you would use
.row {
margin: 0 -5px;
width: 100%;
}
you would see that the widths are equal
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