Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep html buttons at the top of a div

Tags:

html

css

The html buttons behave very diferently in firefox and chrome. Take this example http://jsfiddle.net/nuu1bfe2/.

<div>
    <button>hi</button>
    <button>hi<br/>you, there</button>
</div>

In firefox they are placed in the bottom of the parent but in chrome they are placed in the top. How do I make sure that the buttons are always placed in the top.

like image 548
SiXoS Avatar asked Jun 18 '15 10:06

SiXoS


People also ask

How do you move a button to the top of a div?

Just add position:absolute; top:0; right:0; to the CSS for your button.

How do I keep my div always on top?

Method 1: Using the sticky value of the position property The vertical position of the element to be stuck can also be modified with the help of the 'top' property.

How do you put a button on top of a page in HTML?

You need to absolutely position the buttons inside the header. To do so, add position:relative to the button's parent element and add position: absolute and something like top: 10px; right: 30px; to the buttons.

Can you put a button in a div?

Use the following steps to center align a button in a div container: Create a div container. Insert the button tag. In the CSS for the div set the text-align to center.


1 Answers

Use:

button{
    vertical-align: top;
}

demo

like image 89
Bhojendra Rauniyar Avatar answered Sep 27 '22 21:09

Bhojendra Rauniyar