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

11th Sep 2020, 3:42 PM
Adrián Valdés
Adrián Valdés - avatar
12 odpowiedzi
+ 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!
11th Sep 2020, 3:55 PM
Abhay
Abhay - avatar
+ 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
11th Sep 2020, 4:12 PM
Abhay
Abhay - avatar
+ 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.
13th Sep 2020, 10:57 AM
Chetan Chandel
Chetan Chandel - avatar
+ 1
✌️👍
11th Sep 2020, 9:05 PM
Abhay
Abhay - avatar
+ 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
13th Sep 2020, 11:02 AM
Chetan Chandel
Chetan Chandel - avatar
0
Use align and font-size properties
11th Sep 2020, 3:44 PM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
0
Bro, I know how to change font-size, my question is how to make it adapt to its container dimension automatically
11th Sep 2020, 3:55 PM
Adrián Valdés
Adrián Valdés - avatar
0
Ok <style> div{ height:50vh;} </style> <div> This is a question </div>
11th Sep 2020, 3:57 PM
Adrián Valdés
Adrián Valdés - avatar
0
How to make the text's font size adjust automatically to fit the div's 50vh??
11th Sep 2020, 3:58 PM
Adrián Valdés
Adrián Valdés - avatar
0
Thanks
11th Sep 2020, 4:14 PM
Adrián Valdés
Adrián Valdés - avatar
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) ,
11th Sep 2020, 8:18 PM
Abhay
Abhay - avatar
0
Dont worry, really appreciate you tried to help me😁
11th Sep 2020, 8:57 PM
Adrián Valdés
Adrián Valdés - avatar