Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background is only as wide as view-port

Tags:

html

css

width

Annoying problem!

When I zoom-in on my view-port window (happens in Firefox, chrome) and then scroll horizontally to the right, my background images are clipped

the images best depicts what's happening:

zoom in

zoom in - image is only as wide as view-port

zoom way out - problem doesn't occur

zoom out - problem gone

Here are some sections from my css which might be relevant:

article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}
body{ width: 100%; }
header#header { width: 100%; }
header#header #background-image {
  height: 150px;
  background: url(/images/header/silhouette.png) repeat-x;
} 

This happens with and without cssgradients applied too - really stumped here

like image 278
stephenmurdoch Avatar asked Jan 19 '11 14:01

stephenmurdoch


People also ask

How do I make the background image fit my screen size?

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 make a background in HTML fit the screen?

Fill the Entire Viewport with the background-size Property It is possible to set the CSS background-size property to cover. Using this value, the browser will automatically and proportionally scale the background image's width and height so that they are either equal to or greater than the view port's width and height.

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.

What is view port width?

In an SVG document, the viewport is the visible area of the SVG image. You can set any height and width on an SVG, but the whole image might not be visible. The area that is visible is called the viewport. The size of the viewport can be defined using the width and height attributes of the <svg> element.


1 Answers

The fix for this is to set min-width on the body:

body{ width:100%;min-width: 1002px; }

This fixes problem on all browsers that I have as well as iphone (according to iphonetester although I realise it's probably best to add some media queries now to really give the best solution to handheld users

like image 87
stephenmurdoch Avatar answered Oct 19 '22 04:10

stephenmurdoch