Indeed, then you see white space you don’t want to be visible. I figured I can do it with some sort of jquery or better yet a PHP plugin, but would appreciate any advice. Thanks for the awesome tip! “Awesome, Easy, Progressive CSS3 Way” worked for me! Thank you for excellent post. I’ve been exploring all kinds of non-flash fullscreen solutions for my designs. Hi, how to make non full screen background (centered) but fixed. Alot of people don’t seem to like this, because of little bugs and the evil devil child of the internet design tables. CSS#2 fails as remarked in the article, and the neat CSS3 one works MOSTLY, but the background image experiences a shake (due to a delay in CSS processing, maybe?). 모종의 이유(끔찍하게 잘못된 사이트 디자인 등)로 300x300 픽셀 요소에 저 이미지 4개를 바둑판식으로 보여야 합니다. Will give this a go later. Choosing the right background depends on a host of factors. Watch out guys, there is a bug in Snap Mode in Windows 8 when you do this the CSS3 way. Check out code source… We’ve come a long way. $(body).style(‘background’,’url(phpthumb.php?src=bg.jpg&w=’+w+’&h=’+h+’)’); Would you mind explaining this a little more? Include this syntax to make the background image go full. The goal here is a background image on a website that covers the entire browser window at all times. Hi Chris, you might also want to check out the jQuery plugin fullscreenr I’ve just started using it on a project and it works great! This whole idea becomes a lot easier (from a CSS perspective) if we know if the aspect ratio of the image (inline we intend to use as a background) is larger or smaller than the current aspect ratio of the browser window. Chris, two things happened just now, and we both hope your genius can figure this out, because we have enjoyed your background ‘cover’ method for years. The background property is specified as one or more background layers, separated by commas.The syntax of each layer is as follows: 1. it doesn’t adapt in vertical. The value may be included zero, one, or two times. The problem with tables was lots and lots of them everywhere, for no reason. So it means… javascript. Tip: Use 50% to create a half page background image. http://img29.imageshack.us/gal.php?g=chromeq.jpg these are screenshots taken from my home desktop, but problems are the same @ work, there i’m on XP, here on Win 7. html, body, #bg, #bg table, #bg td { I use this method a lot however I have implemented it on a clients site and she is using a windows phone to view her site and the background is not stretching. But how can I manage that with these codes? Definition and Usage. margin:0; thought about how to do this yesterday, and then you post this today. One question, why use a table? this is all just thinking aloud. If it is possible it uses CSS3, if not, falls back to JS. General Styles http://connerftw.tumblr.com/ #bg img { If it is lower, than we can set only the width to 100% on the image and know it will fill both height and width. 4. Anyhoo… we suspect they know more than us. If you use this, please feel free to leave what technique you used and if you altered it in any way in the comments below. What if a user doesn’t enable JavaScript? This is brilliant, no wonder you have so many posts, everyone ants to know how to do it. Lets all remember that the objective is to design nice looking working sites. The CSS opacity property is a great way to set a low opacity on HTML elements making the entire element semi-transparent including all of its children. http://www.setupsigning.nl/diensten.html I think this is very well done though I do have a theory…. btw, how trick if the image in code css? Dat bunny (today working better than ever before. This post was originally published on August 21, 2009 and is now updated as it has been, This comment thread is closed. I have seen this before too. Though this may only create the resized image on page load… and then the rest of your solution could scale it from there…. We set a min-height which keeps it filling the browser window vertically, and set a 100% width which keeps it filling horizontally. Big thanks, as usual, to Doug Neiner for this alternate version. max-height: auto; Thanks, great read. 2. Seriously, I really am starting to loose steam with this problem….any constructive help or direction at all will be greatly appreciated. It uses jquery but I wouldn’t mind trying to just use CSS 3 to accomplish the same goal. I take it you’d run this on $(window).resize(), not $(document).ready()? For technique 1, there seems to be an issue in Opera 10 if you use the scroll wheel or keyboard arrows down. contain, on the other hand, says to alwaysshow the whole image, even if that leaves a little space to the sides or bottom. You need to add #bg {z-index: -10} or anything else lower than other elements you have on the page. Chris, you are my hero. Okay can somebody please help me? There is also a vertical scrollbar in Opera 10b3, but it’s for the text – however, if I scroll down (without clicking the text first) it will scroll the image instead of the text. Supersize 2.0 looks great. Is this function inside the document ready function? any ideas? I can see the text is under the image, because when I changed in the css top: 0px to top:60px suddenly text was revealed, used second trick but now if i m writting anything on it doen appear. Website can, but is it same with mobile? html{ `{ height: 800px; Alright I documented the current known bugs at the bottom of the article. Never mind, I think it was entirely related to my nested divs, nothing to do with the script. Each layer may include zero or one occurrences of any of the following values: 1. Thanks! This seems like a good solution, specially for clients who can be picky about what gets displayed to visitors. the following does not work: function changeBg(source){ CSS3 cover does a good job of proportionally filling the background with the image. The “bug” refers to this technique, not Firefox itself. It’s embed swf obviously. so is this work on mobile apps too for the background? Something to remember is that it doesn’t work in Internet Explorer below version 9. filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’/testSite/wp-content/themes/BareBones/images/bg3.png’, sizingMethod=’scale’);} I saw this trick some time ago and also used it… it worked like a charm, but at the moment, using safari there is some problem. Never worked for me. Worked perfectly… just used the provided css and updated the images… thanks! Technique 2 is very good addition to the article. There’s a IE filter that can make this CSS3 trick work in any IE version: http://cookbooks.adobe.com/post_Scale_Background_image_to_browser_size-17590.html. When viewport is huge the gap starts to be bigger, if the viewport is smaller the gap disappears and works fine, CSS3 cover does a good job of proportionally filling the background with the image. CSS Technique 2 works for me. Thanks for this btw….Chris, your videos and article have launched me into a new career! Craig Buckler demonstrates a neat trick for applying CSS3 transforms to background images. Great that it works with CSS, but too many bugs to be used effectively. buttons that IE overlays. I will try this on my next project. May be this is late… but I was try full screen background based on the tutorial. We create a simple HTML5 video element with loop, autoplay and muted attributes and place it inside a container element. I’m very happy to find it, indeed. I generally load a standard image of 1280px as background and overload a bigger one in Ajax if the screen is wider. Is it possible to do that? Looks perfect on my 1440px wide screen, but I’ve also tested it on a 1920px wide one and it looks completely acceptable this way. In the following example, as a background-size value, we use “cover”, which scales the background image as much as possible so … Thank you! Learn how to create a full screen video background that covers the entire browser window: Use a default 1280px wide pic with CSS#1, I second @GreLI on his suggestion, even though this does not center the image it is still a nice IE7 fallback. }); And I success to load it each time I change the browser scale. With min-height:640px and min-width:1024px for a 2560×1600 pic it fits almost any resolution/window size decently… *hiding*, Try top:0px;bottom:0px;left:auto;right:auto. background-image:url(images/bg1.jpg); The background property of CSS is used to define the background effects for elements. This was just what I needed for my latest project! What I mean is that bg picture should always have the fix height, width, it should be centered and in case when the browser window width is lower as picture width, the picture should be cropped from both sides (left and right) not scaled. I’ve tried both techniques, by the way. The background is a full screen background that swaps out via a nested div tag. Something to remember is that it doesn’t work in Internet Explorer below version 9. Does it work in all browsers ? In addition to the default value (auto), there are two keywords you can use with background-size: cover and contain cover tells the browser to make sure the image always covers the entire container, even if it has to stretch the image or cut a little bit off one of the edges. Did you check that? Your first technique (css3) poses a problem. Always cool to see techniques “in the wild.”. I suppose it’s a focus problem; anyway for accessibility it would be better to have the focus on the center element. The first value sets the width, the second value sets the height. See this article. There are no empty spaces. html, body, #bg, #bg table, #bg td, #cont { Numbers followed by -webkit-, -moz-, or -o- specify the first version that worked with a prefix. Fills entire page with image, no white space. While Firefox shortly renders the page with a background picture and then redirects to your 404 error page…. background-position:center; If this is no concern to you, CSS3 Cover is a nice option for filling the browser with your background image. Update: Thanks to Goltzman in the comments for pointing out an Adobe Developer Connection article which features some code to make IE do cover backgrounds as well: But careful, reader Pierre Orsander said they tried this and had some problems with links on the page going dead. var theWindow = $(window), fixed and cover didn't use to play well together, and you would have to put the height property in an outer container, but I tested this code on Chrome, Firefox, Safari, and Opera, and it works fine. took me an hour figuring this out. the image (height becomes "auto"), the two-value syntax (first value: width of Good job. Use a media query to serve a smaller background image for mobile devices margin:auto; http://www.type3digital.com/, Yup that question stayed in my head too…:D. I will be using this with one of my clients. If it is higher, we can set only the height to 100% and know that it will fill both the height and width. Can do it with two: top and repeating one but with free no. -webkit-background-size: cover; Thanks for the prompt response. i don’t know how to reach the html-tag. It does not resize the image. min-width:50%; This solution is ugly as sin, a javascript workaround would be far more elegant (if done properly). so i need to add ../images/ to the $image_p and add the mixin with +fullscreen('background/moon', '.jpg'), This hase to be adjusted to your own location of your files. haha, It never ceases to amaze me how much hate tables have generated within the design community :). The code below does it on resize, which you may or may not want. The approach I’m using on my company’s website is an image that fades to black near the borders (it doesn’t fill the entire page though, just the header). We also set a min-width of the width of the image so that the image never gets smaller than it actually is. can we get some help for wordpress users? Hi there, I’m going to use the CSS3 option, and really want to make the background image a link, anyone know how I could achieve this? Here are a few ways to accomplish that: Then instead of loading an img, you’d load a shim. – i.e. If I have any success I’ll reply to this comment and let you know. Oh, I think that’s almost the definition of hate, isn’t it? Background image maintains a fixed ratio. I know… it’s not ‘pure’, but it does the trick so well…. Only Firefox and IE work fine. Question – how do I get the best of both worlds? It’s a mix of CSS and the use of Tables. I find its the best size to use across the board, looks good on a 15″ laptop but still looks good on a 27″ monitor. In the demo, in IE8 at least, the mousewheel only scrolls the content when the cursor is inside the white text container, and it’s somewhat sluggish at large resolutions. Learn how to create a full page background image with CSS. It has been tested back to ie6 and works in most all browsers. 2. Is there any way to change the background on this element dynaically? thank you!! The background-position property in CSS allows you to move a background image (or gradient) around within its container.. html { background-position: 100px 5px; } It has three different types of values: Length values (e.g. Hey Chris, very nice, thanks for posting. Learn how to create a full screen video background with CSS. CSS-only #2 is amazing! Thanks for posting this. The content you concern about with accessibility is on the DIV. Then the image will be placed, still preserving it’s aspect ratio and covering the visible browser window, and the dead center of that. height:100%; For full screen images or websites with full width images I always make them 1920×1280. Get code examples like "css background image cover center" instantly right from your google search results with the Grepper Chrome Extension. There is an in-depth course covering all of CSS, a Sass-specific course, a course on modern layouts, and a course on SMACSS, a approach to CSS architecture. This is one of those CSS Tricks I love to see appear rss feed! Is there a possibility to load the image in background and when finished displaying? It really depends on your theme and any built-in limitations, but considering most users have screens that are at least 1280px wide these days then I would say that probably wouldn’t want to go much less than 1600px. But according to CSS 2.1 «Visual formatting model details» it’s a real bug that absolute positioned image aren’t centered with margin:auto. This changes my approach to design significantly. syntax ("auto", "cover" and "contain"), the one-value syntax (sets the width of Nice follow up to the previous article. Credits for this technique goes to : http://www.g2geogeske.com/ (which is where I first saw this concept and expanded from it).