简体   繁体   中英

Stretching an image as background in IE8

I am trying to stretch an image to the boundaries of the browser in IE8. It is working except the right, left, top, and bottom have white space about the size of 5px. I want the image to stetch COMPLETELY to all sides. My employer has hinted that this is the last straw if I can't get this page right :( Please help if you can..

HTML:

</head>
 <body class="fullbackground">
 <!--THIS IS THE BACKGROUND IMAGE--><img class="fullbackground" src="c:\documents and settings\zx08067\Desktop\Outage_Page\background.png">
    <div class="top">
...
...

CSS:

body {
    position:relative;
}

img.fullbackground {
    position:absolute;
    z-index:-1;
    top:0;
    left:0;
    width:100%; /* alternative: right:0; */
    height:100%; /* alternative: bottom:0; */
    padding-left:0px;
    padding-right:0px;
    margin-left:0px;
    margin-right:0px;
}

Try setting the body tag to have a margin and padding of 0.

body {
    position:relative;
    margin: 0;
    padding:0;
}

Most web browsers have there own default styles on elements. Personally I always use a reset script like: http://meyerweb.com/eric/tools/css/reset/

in your css add

html,body{
padding:0 0 0 0;
margin:0 0 0 0;
overflow-x:hidden; // To remove the bottom scrollbar
}

Hope it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM