I am often faced with a problem where there is just not enough space for all the buttons in one line. Take this fiddle for example. If there is enough space, all element are centered vertically. If the lie breaks, they are pushed into the next line, but they don't maintain proper vertical spacing between them.
The fix I usually employ is to add margin-bottom to the buttons and remove padding-bottom from the container. this is what I mean.
But now I can't reuse my container (.controls class
) with other elements, because not all elements contain buttons that break into next line.
Is there a way to keep a container padding:10px;
and also have a nice line break with vertical spacing between buttons?
.controls {
text-align: center;
background-color: rgb(217, 241, 238);
padding: 10px 10px 10px 10px;
}
button {
font-size: 14px;
background-color: rgb(181, 220, 216);
border: none;
padding: 0.5em 1em;
}
<section class="controls">
<button id="new-file">New File</button>
<button id="open-file">Open File</button>
<button id="save-markdown" disabled>Save File</button>
<button id="revert" disabled>Revert</button>
<button id="save-html">Save HTML</button>
<button id="show-file" disabled>Show File</button>
<button id="open-in-default" disabled>Open in Default Application</button>
</section>