【发布时间】:2013-11-19 14:08:29
【问题描述】:
我在这里使用的布局类似于 Dynamic Drive 中的布局: http://www.dynamicdrive.com/style/layouts/item/css-right-frame-layout/
主要内容区域(白色)的溢出设置为自动。我已经给这个主要内容区域内的 innerTube 一个边框。但是,如果此 innerTube 中的内容大于主内容区域的宽度,则会按预期出现水平滚动条,但在 Firefox 中,这些内容将“重叠”边框并离开屏幕(可以通过水平滚动检索) .换句话说,右边的边框保持在原地,内容刚好越过它的op,消失在右边的列后面。
在 IE 中,它的行为完全符合我的要求 - 内容将边框推离屏幕,只有在您滚动到那里时才可见。
我想最简单的方法就是在这里粘贴源代码。如果您将其复制到空白文件中,您会明白我的意思。我刚刚用了一个很长的词来复制如果有宽幅图像会发生什么。
提前感谢任何可以帮助我的人。
<!--Force IE6 into quirks mode with this comment tag-->
<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body{
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
height: 100%;
max-height: 100%;
}
#framecontent{
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 200px; /*Width of frame div*/
height: 100%;
overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/
background: #cccccc;
color: white;
}
#maincontent{
position: fixed;
top: 0;
left: 0;
right: 200px; /*Set right value to WidthOfFrameDiv*/
bottom: 0;
overflow: auto;
background: #fff;
}
.innertube{
margin: 15px; /*Margins for inner DIV inside each DIV (to provide padding)*/
}
.innertubeWithBorder {
margin: 15px;
border: solid 1px #666666;
}
* html body{ /*IE6 hack*/
padding: 0 200px 0 0; /*Set value to (0 WidthOfFrameDiv 0 0)*/
}
* html #maincontent{ /*IE6 hack*/
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="framecontent">
<div class="innertube">
<h1>CSS Right Frame Layout</h1>
<h3>Sample text here</h3>
</div>
</div>
<div id="maincontent">
<div class="innertubeWithBorder">
<h1>Dynamic Drive CSS Library</h1>
<p>AReallyLongWordWhichIsSimilarToHavingAnImageWithWidthGreaterThanTheWidthOfThisDivToShowOverFlowProblemWithBorderSoIfYouResizeThisWindowNarrowerYouWillSeeWhatIMeanWorksFineInIEButNotFirefox</p>
<p>So I want that border over there ------> to dissappear behind the right hand column like it does in IE, and be visible once you use the scrollbar below and scroll to the right</p>
<p style="text-align: center">Credits: <a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a></p>
</div>
</div>
</body>
</html>
【问题讨论】:
-
这里的问题是您正在强制 IE 怪癖模式。它可以在 Chrome、Safari、Opera 以及所有非 IE 浏览器的 Firefox 中运行。摆脱怪癖模式,找到通用的东西。
-
谢谢克莱图斯。我对 Quirks Mode 知之甚少(主要是我在 quirksmode.org 上读到的)。无论如何,如果摆脱 quirks 模式意味着摆脱代码顶部的注释(即“强制 IE6 进入 quirks 模式”的注释),那么我尝试将其删除,但问题仍然发生在 Firefox 中。不过还是谢谢。