0
Why vertical-align in this code doesnt work?
<style> #test {width: 60%; aspect-ratio: 1 / 1; left: 20%; vertical-align: middle;} </style>
9 Respuestas
+ 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
+ 1
JonySVK
I have never used vertical-align. Doing some tests...
https://code.sololearn.com/Wcg2nSJgkt9N/?ref=app
0
Lisa I want to align the square div exactly to the center of the page.
0
https://www.freecodecamp.org/news/how-to-center-anything-with-css-align-a-div-text-and-more/
What you want is probably the flexbox method.
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?
0
the container element needs to be a flexbox
0
Lisa Can you please advise me how to do it? Thank you.
0
Read the tutorial at the subheading "How to Center Both Vertically and Horizontally"
Link your code if you need help with your code.
0
I already found a way to do it. Thank you very much for your help, Lisa.