gpt4 book ai didi

css - 使用 [margin : 0 auto;] on inner div 时的背景颜色/图像错误

转载 作者:太空宇宙 更新时间:2023-11-04 16:01:24 25 4
gpt4 key购买 nike

在我的示例(下面的链接)中,当浏览器尺寸小于 INNER DIV 的定义宽度 (960px) 时,OUTER DIV 的一些背景会神奇地消失。正如预期的那样,水平滚动条启动了,但是当您向右滚动时,您看不到图像缺失的部分。我相信这与 INNER DIV 的 [margin: 0 auto;] 属性有关,因为当从代码中取出 INNER DIV 时,OUTER DIV 的背景会正常显示(它被截断,但没有滚动条).

任何人都知道为什么会发生这种情况......以及如何解决它?:

http://ryanderson.com/stackoverflow/background/

最佳答案

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Background Problem</title>
<style>
</head>
<body>
<div id="outer">
<div id="inner"></div>
</div>
</body>
</html>

CSS:

body {
margin: 0 auto;
}
#outer {
background: url("background-picture.jpg") no-repeat scroll center top transparent;
height: 500px;
}
#inner {
background: url("diagonal-lines.png") repeat scroll 0 0 transparent;
height: 500px;
margin: 0 auto;
width: 960px;
}

关于css - 使用 [margin : 0 auto;] on inner div 时的背景颜色/图像错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9754685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com