I have the following code and I want to center the text vertically next to the image.
.section_content {
width: 400px;
}
.section_content > ul > li > img {
width: 40px;
height: 40px;
padding: 5px;
}
.section_content > ul > li > a {
vertical-align: top;
}
.section_content > ul > li {
list-style-type: none;
}
.section_content > ul {
list-style-type: none;
padding-top: 45px;
padding-left: 5px;
}
<div class="section_content">
<ul>
<li><img src="img/linkedin.svg"><a href="https://be.linkedin.com/in/lel">LinkedIn</a></li>
<li>GitHUb</li>
</ul>
</div>
You've got vertical-align: top
in there; what you want is vertical-align: middle
, on both the link and the image it's supposed to sit next to.
.section_content {
width: 400px;
}
.section_content > ul > li > img {
width: 40px;
height: 40px;
padding: 5px;
}
.section_content > ul > li > a,
.section_content > ul > li img {
vertical-align: middle;
}
.section_content > ul > li {
list-style-type: none;
}
.section_content > ul {
list-style-type: none;
padding-top: 45px;
padding-left: 5px;
}
<div class="section_content">
<ul>
<li><img src="img/linkedin.svg"><a href="https://be.linkedin.com/in/lel">LinkedIn</a></li>
<li>GitHUb</li>
</ul>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With