I have three buttons inside a wrapper. As you may see in the snippet, the middle one is medium-sized, while the one in the left is wider and the right one is the smallest. I also have in this wrapper a title, which is aligned in the center.
What I'm trying to achieve is to align the buttons (in this case .btns
div) based on the middle button, the medium-sized one. I want that button to be in the center, aligned with the title.
Here is a picture of what I would like the buttons to be aligned:
Although a CSS-only solution is preferable, I'm willing to use JS if needed.
How can I do that?
#content {
background: black;
width: 300px;
height: 150px;
}
#title {
padding-top: 30px;
color: white;
text-align: center;
}
.btns > a {
text-decoration: none;
color: blue;
border: 2px solid red;
}
#b2 {
margin: auto 15px auto 15px;
}
.btns {
display: flex;
justify-content: center;
}
<div id="content">
<h1 id="title">Title</h1>
<div class="btns">
<a href="#">Button Large</a>
<a id="b2" href="#">B Med</a>
<a href="#">B S</a>
</div>
</div>