Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the height of an button (input-element) on webkit browsers?

Tags:

css

button

On my Mac with webkit-browsers (Safari and Chrome, current version) I can't set the height of an input-element.

<input type="button" style="height:200px;" value="Hello World!">​

won't work.

jQuerys $('input').css('height','200px');​ won't work either.

http://jsfiddle.net/XmS6m/

Though setting the width is possible, either with style-attribute or with jQuery.

What is the reason for this inconsistency? And what is a possible solution?

like image 242
MI5 Avatar asked Jun 11 '12 08:06

MI5


3 Answers

Try setting the box-sizing property to content-box:

.my-button {
  box-sizing: content-box;
  height: 200px;
}
like image 123
Lukas Kalbertodt Avatar answered Oct 07 '22 01:10

Lukas Kalbertodt


Display inline-block does nothing, as inputs already have that display set by default. Add border:none. When you do so, it starts behaving like you want it to. Here's the fiddle -> http://jsfiddle.net/joplomacedo/XmS6m/1/

like image 41
João Paulo Macedo Avatar answered Oct 07 '22 02:10

João Paulo Macedo


Button is an inline-level element. You need to change that to block or inline-block:

#my_button { display: inline-block; height: 200px; }

Live Example

like image 39
Madara's Ghost Avatar answered Oct 07 '22 01:10

Madara's Ghost