我试图在 IE8 中将图像拉伸(stretch)到浏览器的边界。除了右边、左边、顶部和底部有大约 5px 大小的空白外,它正在工作。我希望图像能够完全拉伸(stretch)到各个方面。我的雇主暗示,如果我无法正确显示此页面,这是最后一根稻草:( 如果可以,请提供帮助..
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;
}
最佳答案
尝试将 body 标签的边距和填充设置为 0。
body {
position:relative;
margin: 0;
padding:0;
}
大多数网络浏览器在元素上都有自己的默认样式。我个人总是使用重置脚本,例如: http://meyerweb.com/eric/tools/css/reset/
关于html - 在 IE8 中拉伸(stretch)图像作为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16779573/