Home > Mobile >  How do I make my image perfectly centered with the text?
How do I make my image perfectly centered with the text?

Time:01-21

I tried using display flex but they're not perfectly aligned, this image is somehow a bit wider than the text and I don't know how to fix this, this is how it looks on the page enter image description here

#gym {
    width: 10%;
    height: 80%;
}

.side-bar {
    font-family: 'Montserrat', sans-serif;
    display: flex;
    justify-content: flex-start;
    background-color: rgb(230, 224, 224);
    width: 20%;
    height: 80%;
}

.side-bar ul {
    display: flex;
    flex-direction: column;
    margin-left: 10%;
    list-style: none;
    margin-top: 5%;
}

.side-bar ul li {
    margin-bottom: 20px;
}

.side-bar ul a {
    color: black;
    text-decoration: none;
}
<div >
<ul>
    <li><img src="gym.png" alt="gym logo" id="gym"><a href="#">Gym</a></li>
    <li><a href="#">Today</a></li>
    <li><a href="#">This Week</a></li>
    <li><a href="#">Tomorrow</a></li>
    <li><a href="#">Next Year</a></li>
</ul>
</div>

CodePudding user response:

Add into .side-bar ul li display: flex; align-items: center;

CodePudding user response:

This is how it will look

.side-bar ul li {
  margin-bottom: 20px;
  display: flex;
}

.side-bar ul li a {
  align-self: center;
}

.side-bar ul li img {
  align-self: center;
}
  •  Tags:  
  • Related