How can I set the background image to fit the exact size of the browser's window. I am familiar with JavaScript/HTML/CSS/JQuery so any language will work for me.
Asked
Active
Viewed 1.6k times
4
-
3Check out this http://css-tricks.com/perfect-full-page-background-image/ – Nelson Oct 12 '12 at 18:32
-
Possible duplicate of [CSS background image to fit width, height should auto-scale in proportion](http://stackoverflow.com/questions/9262861/css-background-image-to-fit-width-height-should-auto-scale-in-proportion) – Alex Angas Mar 01 '16 at 00:56
4 Answers
2
Thanks to @Nelson 's comment I have found my answer here: http://css-tricks.com/perfect-full-page-background-image/

atomikpanda
- 1,845
- 5
- 33
- 47
0
HTML & CSS:
<html>
<head>
<title>bg</title>
<style>
.bg {
background: url(yourimage);
display: block;
position: absolute;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="bg"></div>
</body>
</html>
0
Try this:
<img src="images/BG.jpg"
style="width:100%;height:100%;position:absolute;top:0;left:0;z-index:-5000;">
http://thewebthought.blogspot.com/2010/10/css-making-background-image-fit-any.html

Tony Wu
- 1,040
- 18
- 28