Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image resizing to fit

I'm trying to make the background image as professional as possible so I'm thinking it's best to resize it based on the size of the browser or the resolution (not sure what's usually used, but I think browser size makes sense here). The idea is if the viewer screen is small, the background image gets smaller, and as the screen gets bigger, the image expands to fit its maximum size.

I will try a CSS or even Javascript (JQuery) solution as needed.

like image 224
vla Avatar asked Sep 26 '10 23:09

vla


People also ask

How can I make my background image resize to fit any screen?

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.

How do you scale a background image?

The background-size CSS property lets you resize the background image of an element, overriding the default behavior of tiling the image at its full size by specifying the width and/or height of the image. By doing so, you can scale the image upward or downward as desired.

How do I fit a full background image in CSS?

There are four different syntaxes you can use with this property: the keyword syntax ("auto", "cover" and "contain"), the one-value syntax (sets the width of the image (height becomes "auto"), the two-value syntax (first value: width of the image, second value: height), and the multiple background syntax (separated ...

What does background-size 100% 100% mean?

background-size:100%; = background-size:100% auto; = the width is set to be 100% large and the height of the background image follows respecting the image aspect ratio.


1 Answers

I guess you're looking for something like that:

http://css-tricks.com/how-to-resizeable-background-image/

like image 179
schnaader Avatar answered Sep 18 '22 19:09

schnaader