简体   繁体   English

IE7可见性错误

[英]IE7 visibility bug

I'm experiencing a visibility: hidden bug in IE7. 我正在经历一个可见性:IE7中的隐藏错误。 My CSS is as follows: 我的CSS如下:

.image {
float:left;
width:298px;
visibility:hidden;
*visibility: hidden;
}

Basically I want everything contained within the div to be hidden, but still occupy and reserve the space (so in this case display: none doesn't work). 基本上我希望隐藏div中包含的所有内容,但仍占用并保留空间(所以在这种情况下显示:none不起作用)。 It works in all browsers except IE7, which seems to ignore the visibility line in the CSS. 它适用于除IE7之外的所有浏览器,IE7似乎忽略了CSS中的可见性行。

Try using text-indent 尝试使用text-indent

.image {
float:left;
width:298px;

text-indent: -10000px;

}

Demo 演示

Dipaks' answer is pretty much what I'd go for too. Dipaks的回答几乎就是我的意思。 A slightly different alternative would be to use left: -10000px; 稍微不同的替代方案是使用left: -10000px; See which works best cross-browser. 看哪个最适合跨浏览器。 If you have any problems with either, try adding position: relative; 如果您遇到任何问题,请尝试添加position: relative; to this and overflow: hidden; 对此和overflow: hidden; to the parent element - I have a hunch (I don't have a copy of IE7 handy to check) that IE might cause the area to increase by 10000px, which will mess up your page widths. 到父元素 - 我有一个预感(我没有IE7的副本方便检查),IE可能会导致该区域增加10000px,这将弄乱您的页面宽度。

添加可见性:隐藏到图像中: http//jsfiddle.net/simply_simpy/n9qZ8/1/

<img class="image" src="http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.gif">​

.image { float:left; width:298px; visibility:hidden; *visibility: hidden; }​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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