Can we give height related to width ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Can we give height related to width ?

Eg. width:80%; height:same as width; or 70% of width; Since screen sizes differ from phone to phone but can the ratio be the same JavaScript or any CSS method ?

14th Apr 2017, 4:22 AM
Utkαrsh
Utkαrsh - avatar
2 Answers
+ 15
This can help :- In Jquery var cw = $('div').width(); $('div').css({'height':cw+'px'});
14th Apr 2017, 4:29 AM
Nikhil
Nikhil - avatar
+ 1
maybe using vh values for the width? g2g is view heigh.
14th Apr 2017, 3:43 PM
זוהר צ'יפרוט
זוהר צ'יפרוט - avatar