Since I like put the word “center” which is inside the yellow box vertically-middle, I tried “vertical-align:middle” many times in the code.
However, the word “center” is not vertically middle.
How can I put the word “center” vertically middle?
The text “center” is not vertically middle at http://form.kr/dest/t12.php of your code.
Is impossible to make it vertically middle by modifying your the code above?
How can I use the flex properties for aligning stuff vertically?
Hi,
The code @PaulOB posted above does align the items vertically.
But the code you link to does not use the flexbox properly. Please try add the align-items:center; to the container ruleblock and see what happens.
Edit)
None of the vertical-align:middle; you have in your css and html is in use when you have the display property set to flex.
As in your linked code:
#container{
display:flex;
text-align:center;
background:yellow;
border-style:solid;
vertical-align:middle;
align-items:center; /* add this to make flexbox work for its children */
}
The inline text formatting model where vertical-align is effective, it is very useful to have a little deeper knowledge, and in case you want to get a grip on the matter I would like to give a link to Eric Meyer’s thorough explanation: https://meyerweb.com/eric/css/inline-format.html