I've read the techniques but after an hour and a half I can't figure out what's wrong.
Am I missing a position?
Why won't the text center vertically?
.subscribe-btn {
display: flex;
margin: 0.5em;
width: 290px;
height: 50px;
background-image: linear-gradient(#4968b0, #3d559e);
border-radius: 20px;
cursor: pointer;
border-style: outset;
justify-content: center;
text-align: center;
}
.subscribe-btn a {
font-weight: bold;
font-size: 16px;
color: white;
text-decoration: none;
}
<div class="subscribe-btn">
<a href="https://www.bridgetodata.org/register">Subscribe to [WEBSITE NAME]</a>
</div>
I've been using combinations of aligning in both the parent and child, trying different displays in the parent and child.
Ok, so first of all you should not be using a
divat all for a link you want to look like a button. You only need the tag that you will style to look like a button. Having thedivbe a part of the button in this case is needless and not semantic. So get rid of that by applying the button class to the element.Then you can simply combine the styles and add
align-items: centerto the styles and you will get what you are looking for. Since you are using flex, you can also get rid oftext-align: center.But honestly unless you need all the buttons the exact same size, it would probably be better to not use flexbox at all and instead set
display: inline-blockand use padding instead of explicit height/width. Also useremoremunits instead ofpxunits for the font-size and the padding. Like this: