Set the height of a div to be half of whatever the width is
问题 How can I set the height of a div to be exactly half whatever the width is, when the width will change depending on the users screen size? I have the following set on a div... #div1 { min-width:400px; width:100%; max-width:1200px; height:400px; background-color:red; } The width works fine on this, it locks at 400 pixels if the screen gets too narrow and it also stops expanding at 1200 pixels if the screen gets too big. But, I also want the height to change to be exactly half of what the width