我有一个名为#lightPole的空div,它有一个灯杆的背景图像。我正在运行一个脚本,让灯杆延长容器的长度。除了IE7之外,大多数浏览器看起来都很好。出于某种原因,我不知道灯杆是否会扩展到页脚之外。有什么想法吗?
这是网站- http://greenlight.mybigcommerce.com/
下面是javascript:
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
$(document).ready(function() { var Container\_height = $('#Container').height(); $('#lightPole').height(Container\_height); });
下面是一些与div相关的css:
#Container {
height:auto;
width: 1100px;
margin: 0 auto;
background-image:url(../images/containerBackground_2.png)!important; /*this is a hack for IE6 to choose between background images*/
background-image:url(../images/containerBackgroundIE6.png);
background-position: center top;
overflow:hidden;
clear:both;
}
#Outer {
clear: both;
height: auto;
margin: 0 0 0 15px;
overflow: hidden;
padding: 0;
width: auto;
}
#Wrapper {
clear: both;
float: left;
height: auto;
margin:9px 0 0 43px;
min-height: 350px;/***added to keep footer from hitting light on nav light pole**/
padding: 0;
width: 990px;
}
#LayoutColumn1{
float: left;
height: 100%;
margin-bottom: 0;
margin-right: 0;
margin-top: 0;
position: relative;
z-index: 88;
clear:both;
}
#lightPole {
background:url(../images/lightPole8aSlice.png);
margin: 0 0 0 19.9px;
/*min-height: 320px;*/
overflow: hidden;
padding: 0;
position: absolute;
width: 15px;
z-index: -100;
display: inline-block;
float: left;
}
更新-这可能是由不正确关闭的div或未清除的浮动引起的吗?
发布于 2011-07-26 06:42:01
我之前遇到了一个类似的问题,它是由于$(Document)函数(.ready())在加载所有图像之前触发的。尝试使用$(window).load(function(){
发布于 2011-07-26 06:52:55
您似乎同时加载了两个版本的jquery : jquery 1.3.2和1.5.2。虽然我还没有将你的问题归结于此,但最好还是删除其中的一个。
发布于 2011-07-26 23:56:50
在我的经验中,我有过图像对以下代码的不同反应:
$('#myimage').height(200);
vs
$('#myimage').attr('height',200);
第一个方法是您正在使用的方法,它将高度添加到style属性中,正如您已经发现的那样,它在大多数浏览器中都工作得很好。
第二个方法设置高度属性本身,并且可以在更多的浏览器中使用。我没有IE7实例,但您可以尝试这样做。
https://stackoverflow.com/questions/6823193
复制相似问题