Languages

CSS - how to center sibling elements vertically in div?

1 points
Asked by:
Jacob
532

I have image and link with text inside a div element.

How can I center all elements inside this div vertically?

Below code will output the the result like this:

As we can see the 'Created by:' span and 'Username' a href element are at the bottom of the line, but I'd like to have them in the middle of the picture, how to make it work?

My code:

I uploaded mini pic used in this example:

 

1 answer
1 points
Answered by:
Root-ssh
178290

Quick solution:

We just need to add display: flex; align-items: center; to outer div.

Full working code example:

It will produce the result like this:

All elements should be in the middle of the picture :D

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join