Reputation: 1329
I have three buttons and i want to align them in a row and they should get equal space.
For example i have something like this:-
<div class='parent'>
<button class='child'> Button 1 </button>
<button class='child'> Button 2 </button>
<button class='child'> Button 3 </button>
</div>
Now i want to align all the buttons in a single row having equal space so that if i add another button in future i don't need to worry and every button will have equal space.
Upvotes: 6
Views: 25420
Reputation: 550
You should study about Flex
. Here is solution...
.parent {
width: 100%;
display: flex;
justify-content: space-around;
}
.child {
}
<div class='parent'>
<button class='child'> Button 1 </button>
<button class='child'> Button 2 </button>
<button class='child'> Button 3 </button>
</div>
Upvotes: 2
Reputation: 1401
This will work. I highly recommend you to read more about flex as this is essential for CSS styiling.
.parent {
display: flex;
justify-content: space-between;
}
<div class='parent'>
<button class='child'> Button 1 </button>
<button class='child'> Button 2 </button>
<button class='child'> Button 3 </button>
</div>
Upvotes: 10