CSS question
- Started
- Last post
- 6 Responses
- nosaj
Is there a way to have a div's height change proportionally to the width? For example, if I have a div that is a square with width:75% as I resize the browser window width, I want the div to remain a square not just the width to change.
- nosaj0
The same behavior as setting an image's width in % only with a div.
- dbloc0
?
height: auto;
- nosaj0
Sorry, I should have mentioned - the div contains a js animation that goes beyond the dimensions of the div (images sliding around) and overflow:hidden. So height: auto won't work.
- albums0
short answer: no
medium answer: yes (w/javascript)
long answer: you would want something that monitors the div width then reports that number back to the height. It'd either be jerky; constantly refreshing or would snap to height after the frame size was established.
- mikotondria30
Why will you be resizing your window ? What kind of UX is this ??