Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are button, input vs div, a have different width result?

Here is the js bin http://jsbin.com/ojiJEKa/1/edit

Sorry for my stupid question, but, why <div> & <a> have different width result with <input> & <button>? Even they have same style

How to make them equal?

like image 613
Drizzle Cloudy Avatar asked Dec 07 '25 21:12

Drizzle Cloudy


2 Answers

The button and input element have a box-sizing set to border-box by default. This mean the padding and border are bounded inside the defined width.

That is not the base with the a and div elements, has they have normal box-sizing property. This mean padding and border are added extra on top of the width.

To make them all the same, normalize the box-sizing css property.

like image 162
Simon Boudrias Avatar answered Dec 09 '25 09:12

Simon Boudrias


input and button have different box model, you can add "box-sizing:content-box" to them to reset the box model.

like image 30
chunterg Avatar answered Dec 09 '25 10:12

chunterg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!