So i've got this issue with my CSS where I cannot display a text-link inline with my image. The links are on a different height relative to my image? What can the issue be? I've tried using different alignment methods such as vertical-align etc.
Maybe I should rewrite the whole code?
html,
body {
font-family: 'Open Sans', sans-serif;
background-color: #efefef;
}
body{
margin: 0;
}
.left_div {
margin: 0;
padding: 0;
width: 25%;
background-color: #fff;
position: fixed;
height: 100%;
overflow: auto;
text-align: center;
}
.left_div img {
width: 50%;
height: auto;
margin: 2vh 0 2vh 0;
}
.left_div a {
display: block;
color: black;
background-color: rgb(217, 50, 141);
padding: 16px;
text-decoration: none;
width: 75%;
margin: 2vh auto;
border-radius: 5px;
color: rgb(255, 255, 255);
transition: all .2s ease-in-out;
}
.left_div a.active {
background-color: rgb(65, 29, 100);
color: white;
}
.left_div a:hover:not(.active) {
background-color: rgb(153, 22, 94);
color: white;
}
@media screen and (min-width: 765px) and (max-width: 968px) {
.left_div {
width: 100%;
height: auto;
position: relative;
text-align: left;
}
.left_div img {
width: 12.5%;
height: auto;
margin: 0 0 0 2vw;
}
.left_div a {
display: inline;
color: black;
background-color: rgb(217, 50, 141);
padding: 16px;
text-decoration: none;
margin: 0 auto;
border-radius: 5px;
color: rgb(255, 255, 255);
transition: all .2s ease-in-out;
}
}
@media screen and (max-width: 765px) {
.left_div {
width: 100%;
height: auto;
position: relative;
}
.left_div a {
text-align: center;
float: none;
}
}
<!-- HTML -->
<div class="left_div">
<img src="img/mlp_logo.png" alt="My Little Pony Logo">
<a class="active" href="#">Home</a>
<a href="#">News</a>
<a href="#">Contact</a>
<a href="#">About</a>
</div>
Here is a jsfiddle to show the issue.
Thanks!
edit (screenshot added)
https://i.sstatic.net/o6S4L.jpg As you see on the screenshot the image and text are misaligned height-wise.
As already stated in the comments, setting the proper vertical alignment did the trick:
Solution was to add:
.left_div img {
vertical-align: middle;
}