Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a css tiled / repeated background stay sharp on a retina screen?

Tags:

css

iphone

safari

On the web page, I'm scaling all of my images by 50% with CSS to make them look sharp on retina screens but that doesn't work for tiled images, there seems to be no way to scale a tile background image so that it will be sharp and not doubled sized on the retina screens. Sorry if this question is confusing.

like image 632
missaghi Avatar asked May 09 '12 19:05

missaghi


People also ask

Which background CSS property would cause the background image to repeat vertically?

repeat-y: This property is used to set the background image repeated only vertically.

Which way by default a background image will repeat?

By default, a background-image is repeated both vertically and horizontally. Tip: The background image is placed according to the background-position property. If no background-position is specified, the image is always placed at the element's top left corner.

How do you make a background image fit your screen in CSS?

Using CSS, you can set the background-size property for the image to fit the screen (viewport). The background-size property has a value of cover . It instructs browsers to automatically scale the width and height of a responsive background image to be the same or bigger than the viewport.

Which CSS property is responsible for repeating an image both horizontally and vertically?

The background-repeat property in CSS is used to repeat the background image both horizontally and vertically.


1 Answers

Setting background-size: 150px 150px; for a 300x300 background image seems to do the trick. Note that background-size: 50%; will not do what you might expect, as it sets the width and height to 50% of the parent container.

like image 58
Kaivosukeltaja Avatar answered Oct 25 '22 15:10

Kaivosukeltaja