is there a way to set the number of times a background image repeats with css?
The background-repeat property sets if/how a background image will be repeated. By default, a background-image is repeated both vertically and horizontally. Tip: The background image is placed according to the background-position property.
background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial| inherit; Default Value: Its default value is initial. Property Values: repeat: This property is used to repeat the background image both horizontally and vertically.
The background-repeat property in CSS is used to repeat the background image both horizontally and vertically. It also decides whether the background-image will be repeated or not. Background-repeat: This property is used to repeat the background image both horizontally and vertically.
An ugly hack could be inserting multiple times —statically— the same image (using multiple backgrounds):
E.g. To repeat horizontally an image (80x80) three times:
background-image: url('bg_texture.png'), url('bg_texture.png'), url('bg_texture.png'); background-repeat: no-repeat, no-repeat, no-repeat; background-position: 0 top, 80px top, 160px top;
Beware: not working on IE under 9 version (source).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With