I'm having a scenario where the text has to be centered into a div which should have aspect ratio. I do not want to use aspect-ratio
as a lot of main browsers like safari do not support that.
Here is my code on what I've done now:
.aspect-ratio-div{
background-color: #f2f2f7;
position: relative;
width: 100%;
padding-top: 33.33%;
}
.text{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align: center;
font-size: 20px;
color: white;
}
<html>
<div class="aspect-ratio-div">
<label>This is some centered text</label>
</div>
</html>
This would work fine for images, as I have learnt but what about for texts?
This is the output which I would like..
the white space should be in 1:3 ratio and the text always in center of it.
What would be a good approach ??
I got what I wanted thanks!!!