69

I am trying to create a page background with an overlay using 's multiple background support;

html, body {
  background: url('https://github.com/jaysalvat/vegas/raw/master/overlays/01.png') repeat,
              url('http://farm8.staticflickr.com/7260/7502004958_595bf03fbf_z.jpg') top left no-repeat;
  background-size: cover;
}​

I want the photo background image to "cover" the page and the overlay to be small (3*3px) repeating over the hole page.

The above example gives me http://jsfiddle.net/tpmD4/ (also the overlay covering the page).

How can I fix that?

When I try to specify the for both of the images (background-size: 3px 3px, cover;); then the image background doesn't cover, but the overlay works.

3
  • 1
    Not sure if what you're trying to do is possible, but it seems like it should be as it would make sense to be able to specify the background-size property for each image. Only think I can think to do is place a div with width & height 100% and place your second background image on that div. Commented Jul 13, 2012 at 10:32
  • This page suggest that it should work: css3.info/preview/background-size ---- #examplen { width: 580px; height: 200px; background-image: url(img/sheep.png), url(img/sheep.png), url(img/betweengrassandsky.png); background-repeat: no-repeat; background-position: 20px 100px, 400px 50px, center bottom; background-color: #EEE; background-size: 70px, auto, cover; } Commented Jul 13, 2012 at 10:37
  • Okey I also think it should be posible, I have thought about your idea but I am just trying to avoid the second div if it is posible.. thx! Commented Jul 13, 2012 at 10:37

1 Answer 1

116

Here you go:

html, body {
    background-image: url(01.png), url(z.jpg);
    background-repeat: repeat, no-repeat;
    background-position: 0 0;
    background-size: 3px 3px, cover;
}

http://jsfiddle.net/tpmD4/6/

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

3 Comments

Of course, you don't want to have a single small image cover the whole background, you want to repeat it at the proper size! Thanks so much for this!
It might be maybe something broken in the latest version of chrome, but the background-size and position properties aren't doing anything for me. Comma separated backgrounds work just fine though.
@Gopherkhan I know this is a late reply but just in case. I had a similar issue with background-size, the issue was with using inherit or initial when doing multiple sizes. Using auto instead fixed the issue for me. A bit more of an explanation here

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.