I have a simple HTML code which contains three button inside a flex div as bellow;
When a user click on any of the buttons, that button will have the active
class.
.box {
width: 100%;
background-color: red;
text-align: center;
}
.flexbox {
width: 100%;
justify-content: center;
}
.active {
background-color: yellow;
}
<div class="box">
<h4>HELLO</h4>
<div class="flexbox">
<button class="active">ONE</button>
<button>TWO</button>
<button>THREE</button>
</div>
</div>
What I need to achieve here is the button contain the active
class should always be centre aligned in side the flex box
.
According to the above, the button ONE has the active
class and it should be centre aligned in side the flexbox
and other two buttons should go right.
You can get the idea from the image below
NOTE: Preferred to solve this with use CSS only.