I have an anchor tag and I have given it a height and a background colour, but I can't get the text to vertically align in the middle of the background colour.
I want there to be equal background colour above and below the text, but the height is all being added below the text. I don't think that I can use padding, given the implementation of this (see the codepen link), I've also tried display: table
on the parent and table-cell
on the link etc, and applying a line-height
.
Here is the code, but the codepen will better explain what I would like to do:
HTML:
<div class="border">
<a href="#">Link</a>
</div>
SCSS:
.border {
display: inline-block;
width: 200px;
height: 70px;
border: 2px solid #2BD6C5;
position: relative;
}
a {
display: inline-block;
vertical-align: middle;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
height: 80%;
width: 90%;
text-align: center;
color: #FFF;
font: 24px sans-serif;
text-decoration: none;
background-color: #2BD6C5;
transition: 250ms ease-in;
&:hover {
width: 100%;
height: 100%;
}
}