This is my first answer, but hopefully it helps!
* {
font-size: 9px;
}
#container{
border: 3px solid black;
text-align:center;
min-height: 200px;
}
.valign_outer{
}
.valign_inner{
padding-top: calc( (200px - 9px) * 1.2) ;
padding-bottom: calc( (200px - 9px) * 1.2);
}
You can set any font-size.
You can set any min-height.
You can choose the padding-multiplier that best suits you.
You may redo this calculations for different Media Queries.
The calculation is: calc( (min-width - font-size) * padding-multiplier )
Make sure the padding multiplier is at least 0.5 on both.
This is the logic:
When you set a fixed height or a vh height, it is tricky: either the font-size always resizes not to overflow the height, or on smaller widths, you would get line-breaks and text may overflow the height.
And font-resize is not always best: we may want some CSS locks: see https://fvsch.com/css-locks/
So, we cannot determine the height of the container. But, we can define the min-height.
So, the text is going to occupy some size, and to center it, we want the same padding-top and padding-bottom
Now, that padding is better defined based on the font-size. If font is 20px, make the padding 20px maybe, but if font is 40px, make padding 40px, for example.
Also, we have to account for remaining space. If min-height is 200, the text is at least font-size high. It may be more, if there are line breaks, but if font-size is 16px, at least the text occupies 16px vertically.
So out of 200, we have 200 - 16 = 184 pixels available at most, to divide into our padding-top and padding-bottom.
You have to make sure the padding is at least ((min-width - font-size) / 2) to account for this scenario!
Hope it helps!