What is the best way to display a full-screen image across any monitor resolution using just CSS and HTML?
-
With just one image, and no javascript.
-
Answer:
If using as background for the body: body { background: url("http://dl.dropbox.com/u/40036711/Images/BeerSpill.jpeg") fixed no-repeat centercenter transparent; -moz-background-size: cover; background-size: cover; } Working example: http://jsfiddle.net/callmepc/zm3pq/5/embedded/result/ If using an element other than body (like div) use this #fullPageBG { background:url("http://dl.dropbox.com/u/40036711/Images/BeerSpill.jpeg" fixed no-repeat center centertransparent; -moz-background-size: cover; background-size: cover; width:100%; height:100%; position:absolute; } Here's the jsFiddle: http://jsfiddle.net/callmepc/DbVVy/3/embedded/result/ (With a big glass of beer!)
Prashant Chaudhary at Quora Visit the source
Other answers
The background-size property: http://www.alistapart.com/articles/supersize-that-background-please/ Compatibility: http://www.quirksmode.org/css/background.html#size
Aen Tan
If you're looking to have an image take up the full monitor, I don't think that's possible w/ just HTML and CSS. Even w/ JS, some browsers let users disable client-side window resizing.
Allen Cheung
Related Q & A:
- What is the best way to calculate a date difference?Best solution by Stack Overflow
- What's the safest way to clean a laptop screen?Best solution by Yahoo! Answers
- What's the best way to get a job in a restaurant?Best solution by Yahoo! Answers
- What's the best way to make a good impression at a job interview?Best solution by Yahoo! Answers
- What is the best way to negotiate a salary for a new position?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.