Why is there an unexplainable gap between these inline-block div elements? [duplicate]

In this instance, your div elements have been changed from block level elements to inline elements. A typical characteristic of inline elements is that they respect the whitespace in the markup. This explains why a gap of space is generated between the elements. (example) There are a few solutions that can be used to solve … Read more

Set padding for UITextField with UITextBorderStyleNone

I found a neat little hack to set the left padding for this exact situation. Basically, you set the leftView property of the UITextField to be an empty view of the size of the padding you want: UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)]; textField.leftView = paddingView; textField.leftViewMode = UITextFieldViewModeAlways; Worked like a … Read more

How can I pad a String in Java?

Since Java 1.5, String.format() can be used to left/right pad a given string. public static String padRight(String s, int n) { return String.format(“%-” + n + “s”, s); } public static String padLeft(String s, int n) { return String.format(“%” + n + “s”, s); } … public static void main(String args[]) throws Exception { System.out.println(padRight(“Howto”, … Read more

When to use margin vs padding in CSS [closed]

TL;DR: By default I use margin everywhere, except when I have a border or background and want to increase the space inside that visible box. To me, the biggest difference between padding and margin is that vertical margins auto-collapse, and padding doesn’t. Consider two elements one above the other each with padding of 1em. This … Read more