Search code examples
htmlfixedcss

css item width percent in fixed position div?


I'm trying to have an image inside of a position:fixed div respond to the width of the browser.

The img is inside of a 100% width div with a margin of 100px on both sides, and those are both inside of a div with a max-width of 750px, all inside of a div that is fixed position.

Once the browser is resized to something less than 750px, normally, the image would begin sizing down automatically. It seems that since it's in a fixed position that it is just getting cut off. Is there a way around this, with the div still remaining fixed?


Solution

  • You'll want to give the image element a percentage width e.g. img{width:100%;}

    http://jsfiddle.net/jg6va/