Let's take this example you used:
CSS:
#foo {
max-width:100%;
background:url(images/myimage.png) no-repeat 0 0;
}
HTML:
<div id="foo"></div>
Here you have defined that the div has a maximum width of 100% and that it has a background image (myimage.png) but you've not specified that the background-size is 100%, so if the image is larger than the div, it will appear full-size and clipped (to the right, because you specified the image position as 0,0 meaning place this background top left. If you added background-size:100%, then the background should fit the div. You might also want to consider not using max-width on the div, I may be wrong but I suspect simply using width:100% would work.
Your other example is not using a background image. It is a foreground image placed inside a div, so here you want the div size to be defined in the CSS and for the foreground image to be positioned and scaled within that div, e.g.
<div id="foo"><img src="images/ornaments.png" /></div>
#foo {
width:100%;height:auto;
}
#foo img {
width:100%;height:auto;
}
This would mean that the div will occupy the full width of the parent (I assume the width of the screen in your case) but also that the image contained within the div will occupy the full width of the div you just defined.
If it really is a background image you ideally want to use, then elect for the former. If the image is genuinely a foreground image, use the latter.
By the way, the latter could be done more elegantly but I've just laid it out long-hand to illustrate the meaning behind the process.