You may want to try setting it as an element background and then use the background-size property.
HTML Code:
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
.imgElem {
background: url('images/last.png');
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body>
<div class="imgElem"></div>
</body>
</html>
But of course this is a CSS3 property that wouldn't be supported in IE8- or very old version of other browsers. In the event support for 'less-than-modern' browsers is required you can simply set the img element to have a width and height of 100%.
HTML Code:
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<img src="images/last.png" alt="starting" style="width: 100%;" />
</body>
</html>
I didn't set both the width and height only because that can cause distortion in an image when the browser window does not match the resolution ratio of the image. This would mean that in some cases there may be 'blank' space on either the top or sides of the image, but depending on the actual image, it could be a simple fix to just fade the edges in to whatever color you choose to be the background of your webpage. If not then simply add 'height: 100%;' after the width property and it will always stretch to the user's browser window dimensions.
Bookmarks