0

Why vertical-align in this code doesnt work?

<style> #test {width: 60%; aspect-ratio: 1 / 1; left: 20%; vertical-align: middle;} </style>

15th Nov 2023, 3:12 PM
JonySVK
JonySVK - avatar
9 Answers
+ 1
It depends on what element you try to align. Have a look at the documentation and note that it is supposed to align inline elements. https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align?retiredLocale=en
15th Nov 2023, 4:08 PM
Lisa
Lisa - avatar
+ 1
JonySVK I have never used vertical-align. Doing some tests... https://code.sololearn.com/Wcg2nSJgkt9N/?ref=app
16th Nov 2023, 2:24 AM
Bob_Li
Bob_Li - avatar
0
Lisa I want to align the square div exactly to the center of the page.
15th Nov 2023, 4:13 PM
JonySVK
JonySVK - avatar
15th Nov 2023, 4:23 PM
Lisa
Lisa - avatar
0
Lisa I wrote this: #test { width: 60%; aspect-ratio: 1 / 1; left: 20%; display: flex; justify-content: center; background-color: green; position: fixed; overflow: scroll; z-index: 1000000; } But it still doesn't work. What else am I missing?
15th Nov 2023, 4:26 PM
JonySVK
JonySVK - avatar
0
the container element needs to be a flexbox
15th Nov 2023, 4:53 PM
Lisa
Lisa - avatar
0
Lisa Can you please advise me how to do it? Thank you.
15th Nov 2023, 5:27 PM
JonySVK
JonySVK - avatar
0
Read the tutorial at the subheading "How to Center Both Vertically and Horizontally" Link your code if you need help with your code.
15th Nov 2023, 5:40 PM
Lisa
Lisa - avatar
0
I already found a way to do it. Thank you very much for your help, Lisa.
15th Nov 2023, 5:44 PM
JonySVK
JonySVK - avatar