图片和 link 对齐问题

Issue with image and link alignment

所以我的 CSS 遇到了这个问题,我无法显示与我的图像内嵌的文本 link。 link 的高度与我的图片不同?问题是什么?我尝试过使用不同的对齐方法,例如垂直对齐等

也许我应该重写整个代码?

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>

这里有一个 jsfiddle 来说明这个问题。

https://jsfiddle.net/bcyu0f52

谢谢!

编辑(添加了屏幕截图)

https://imgur.com/hwbmAKR 正如您在屏幕截图中看到的那样,图像和文本在高度方向上未对齐。

由@SaschaM78 解决。

I think you want to have your a tags vertically aligned with the image, right? If so, add vertical-align: middle; to .left_div img. Updated fiddle can be found here - @SaschaM78

谢谢!我的一个小菜鸟错误。

如评论中所述,设置正确的垂直对齐方式就可以了:

解决方案是添加:

.left_div img {
  vertical-align: middle; 
}