Why were margin collapse rules introduced in CSS?

This is one of the situations where it doesn’t really make sense until you realise that the alternatives make less sense. As you probably know, margins specify the distance between elements, it’s not an “outer padding” that surrounds each element. If two elements with the margin 20px are next to each other, the distance between … Read more

How to adjust gutter in Bootstrap 3 grid system?

You could create a CSS class for this and apply it to your columns. Since the gutter (spacing between columns) is controlled by padding in Bootstrap 3, adjust the padding accordingly: .col { padding-right:7px; padding-left:7px; } Demo: http://bootply.com/93473 EDIT If you only want the spacing between columns you can select all cols except first and … Read more

Align a div to center

There is no float to center per se. If you want to center a block element inside another do this: <div id=”outer”> <div id=”inner”>Stuff to center</div> </div> with: #outer { width: 600px; } #inner { width: 250px; margin: 0 auto; } Now that won’t make the text wrap around it (like it would with a … Read more

jQuery How to Get Element’s Margin and Padding?

var bordT = $(‘img’).outerWidth() – $(‘img’).innerWidth(); var paddT = $(‘img’).innerWidth() – $(‘img’).width(); var margT = $(‘img’).outerWidth(true) – $(‘img’).outerWidth(); var formattedBord = bordT + ‘px’; var formattedPadd = paddT + ‘px’; var formattedMarg = margT + ‘px’; Check the jQuery API docs for information on each: outerWidth innerWidth width Here’s the edited jsFiddle showing the result. … Read more

CSS Cell Margin

A word of warning: though padding-right might solve your particular (visual) problem, it is not the right way to add spacing between table cells. What padding-right does for a cell is similar to what it does for most other elements: it adds space within the cell. If the cells do not have a border or … Read more

UITableViewCell with autolayout left margin different on iPhone and iPad

 How to fix it After fighting with the apple bug reporting team with many sample projects and screenshots and dissecting that answer, I’ve found that the solution to have your custom-style cells behave consistently regarding their margins and be just like the default UITableViewCells, you have to do the following (mostly based on Becky’s answer, … Read more