3 ms·
Modded up, but I really hope most frontend folk on HN already know about border-box. Short ver: float two 50% widths beside each other. Change padding as you l
by nailer 13y ago
Modded up, but I really hope most frontend folk on HN already know about border-box.
Short ver: float two 50% widths beside each other. Change padding as you like later and not have stuff break.
I have been doing this for a year now, it's godlike especially for in-browser design.
- untog 13y agoAnother great use is combining percentages with pixel values. 100% wide with a 30px border? Simple. Used to be impossible with only one element.
- yogo 13y agoBorder box is also a godsend when dealing with nicely laid out form inputs because unlike elements like divs you can't get away with nesting child elements to get the desired effect, and you typically have borders on those fields. Need a textarea to fill a certain space? Set it to 100% and forget it.
- talmand 13y agoFrom my understanding most browser use border-box on form elements by default anyway. That's why they often look different from other elements with the same styling.
- yogo 13y agoI don't think so. There are endless blog articles online that have addressed this, e.g. http://davidwalsh.name/textarea-width http://davidwalsh.name/textarea-width
- talmand 13y agoI was going by this, http://www.paulirish.com/wp-content/uploads/2011/gplus-boxsizing.html http://www.paulirish.com/wp-content/uploads/2011/gplus-boxsi..., which I believe doesn't include textarea as one of the elements involved.