I have an img if I give it a width:100%; and no height. When the window change, the width adapts to its parent and the height keeps the proportion. Can I make a div behave the same way?
For different reasons, I need the div be the width and height than the img. In this case, the img original size is 600 x 300 px.
The example here to play: http://jsfiddle.net/r05zpdd0/
HTML:
<img src="http://www.w3.org/html/logo/downloads/HTML5_sticker.png"/>
<div id="nota">some text</div>
CSS:
img {
position:relative;
margin:0 auto;
width:100%;
}
div {
position:relative;
margin:0 auto;
width:100%;
text-align: center;
display: inline-block;
background: blue;
}