Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack buttons vertically

Tags:

html

css

I am wondering how can I make some buttons to stack vertically and not horizontally in css.

So, the html would be like:

<button>Test<button>
<button>Test<button>
<button>Test<button>

And those buttons will by default stack horizontally, what I want is to make them stack vertically (so everyone's on top of the next button).

like image 924
Oscar Arranz Avatar asked Feb 28 '17 20:02

Oscar Arranz


People also ask

How do I make buttons stack vertically in HTML?

Use the . btn-group-vertical class in Bootstrap to make a button group appear vertically stacked.

How do you align buttons vertically?

Other than flexbox property, we can also center align the button horizontally and vertically using a set of CSS properties. Add position: relative to the container class and position: absolute to the class containing the button. Now use left:50% and top:50% to position the button to the center of the container.

How do I make two buttons vertically in HTML?

Add button { display: block; } to your CSS. Buttons by default are inline elements, which will stay on the same line when possible. block elements on the other hand (like divs), will be forced to a new line.

How do I arrange buttons in HTML?

You can wrap the buttons with container divs and leverage Flexbox to justify the contents in the center. It's important to give the buttons the same size, so that they align properly, and scale the containing divs accordingly so that the buttons don't overflow or wrap.


1 Answers

Define the buttons as block-level elements. Also, note the use of the correct closing tag (</button>):

button {
    display: block;
}
<button>Test</button>
<button>Test</button>
<button>Test</button>
like image 163
BenM Avatar answered Oct 27 '22 11:10

BenM