1

I need to put a large cover image at the top of a page. It's wider than my 960px content wrapper so I'll put it outside of that, but I don't want it causing the page to scroll horizontally due to its width. Is there an established way to make a container ignore a specific child when it comes to scrolling?

My first thought was to make it the centered background of a div with 100% width, but the image is dynamic and shouldn't be assigned by the CSS.

1
  • I still want the page to scroll horizontally if it gets thinner than the wrapper, and I don't want to scale the image, it should be fixed width. Commented Jan 20, 2013 at 21:49

1 Answer 1

1

You can set max-width:100% on the image, this will scale it down to fit if it's too big at full size (just make sure that height is either not set or auto)

Alternatively, you can use a background image, but have the "image" part be none in your external CSS. Then, where you would have src="path/to/image.png" in your <img />, instead just put style="background-image:url('path/to/image.png');"

Sign up to request clarification or add additional context in comments.

1 Comment

thinking the second might be the best scenario

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.