0
Does anyone know how to make font-size of a paragraph adjust to cover its container(div) width and height???
Font-size in divs
12 Réponses
+ 3
Maybe a sample code of what you are trying to do will help others in a better understanding of what you are trying to achieve!
+ 2
Adrián Valdés something like this ?
div{
height:50vh;
width:50vw;
background-color:cyan;
font-size:calc(50vh * (6 / 100));
}
Initially I have set font size 15.36 px by doing that according to my screen height ,which changes the font size according to divs height either it decreases or increases , see if this works for you
+ 2
There are ways to make child element's dimensions adjust automatically according to its parent element but I don't think it can be done with font size.
+ 1
✌️👍
+ 1
https://developer.mozilla.org/en-US/docs/Web/CSS/font-size#:~:text=If%20you%20haven't%20set,%3D%2020px%20and%202em%20%3D%2040px.
Ok so apparently we can set font size relative to the parent element's font size but still can't find a way to set it relative to the element's dimensions. Adrián Valdés
0
Use align and font-size properties
0
Bro, I know how to change font-size, my question is how to make it adapt to its container dimension automatically
0
Ok
<style>
div{ height:50vh;}
</style>
<div>
This is a question
</div>
0
How to make the text's font size adjust automatically to fit the div's 50vh??
0
Thanks
0
I am not sure if it worked out for you or not since it makes the font size much smaller when height of container reduces so not an ideal solution ,and I haven't find any other way but you may go through tutorials available on net and search more about the topic(sorry can't suggest one) ,
0
Dont worry, really appreciate you tried to help me😁