div width auto !important 似乎在 ie6/ie7 中不起作用
HTML
<div class="grid_11 omega" id="homeGalleryFichaGold">
<div class="contSlideGalleryUp" style="display: none;">
<a href="javascript:;" onclick="$('#panelGallery').slideToggle(); $('.contSlideGalleryUp').hide(); $('.contSlideGalleryDown').slideToggle('slow');" id="openGallery" class="openGallery" title="">HOTEL GALLERY</a>
</div>
<div style="display: block;" class="contSlideGalleryDown">
<a href="javascript:;" onclick="$('#panelGallery').slideToggle(); $('.contSlideGalleryUp').slideToggle('slow'); $('.contSlideGalleryDown').hide();" id="closeGallery" class="closeGallery" title="">HOTEL GALLERY</a>
</div>
<div style="display: block;" id="panelGallery">
<ul>
<li class="selected"><a class="photos" href="#" title=""><span>PHOTOS</span></a></li>
<li><a class="videos" href="#" title=""><span>VIDEOS</span></a></li>
<li><a class="suites" href="#" title=""><span>SUITES 3D</span></a></li>
<li><a class="location" href="#" title=""><span>LOCATION</span></a></li>
<li><a class="publication" href="#" title=""><span>PUBLICATION</span></a></li>
<li><a class="tour" href="#" title=""><span>INTERACTIVE TOUR</span></a></li>
<li><a class="panorama" href="#" title=""><span>PANORAMA</span></a></li>
<li><a class="googlearth" href="#" title=""><span>GOOGLE EARTH</span></a></li>
</ul>
</div>
</div>
基本上我无法让 #panelGallery 在 IE6/7 中具有“自动”宽度(在所有其他版本中都可以正常工作)
CSS
#panelGallery {
background-color: #333;
color: #FFFFFF;
float: right;
font-size: 11px;
font-weight: bold;
height: 65px;
line-height: 65px;
opacity: 0.9;
/*width: 640px;*/
position:absolute;
bottom: 0px;
right:0px;
}
.contSlideGalleryDown {
position:absolute;
bottom: 65px;
right:0;
}
我为 ie6/7 添加了这个 hack
#panelGallery {
*width: auto !important;
}
但仍然使用所有宽度
THE HTML
<div class="grid_11 omega" id="homeGalleryFichaGold">
<div class="contSlideGalleryUp" style="display: none;">
<a href="javascript:;" onclick="$('#panelGallery').slideToggle(); $('.contSlideGalleryUp').hide(); $('.contSlideGalleryDown').slideToggle('slow');" id="openGallery" class="openGallery" title="">HOTEL GALLERY</a>
</div>
<div style="display: block;" class="contSlideGalleryDown">
<a href="javascript:;" onclick="$('#panelGallery').slideToggle(); $('.contSlideGalleryUp').slideToggle('slow'); $('.contSlideGalleryDown').hide();" id="closeGallery" class="closeGallery" title="">HOTEL GALLERY</a>
</div>
<div style="display: block;" id="panelGallery">
<ul>
<li class="selected"><a class="photos" href="#" title=""><span>PHOTOS</span></a></li>
<li><a class="videos" href="#" title=""><span>VIDEOS</span></a></li>
<li><a class="suites" href="#" title=""><span>SUITES 3D</span></a></li>
<li><a class="location" href="#" title=""><span>LOCATION</span></a></li>
<li><a class="publication" href="#" title=""><span>PUBLICATION</span></a></li>
<li><a class="tour" href="#" title=""><span>INTERACTIVE TOUR</span></a></li>
<li><a class="panorama" href="#" title=""><span>PANORAMA</span></a></li>
<li><a class="googlearth" href="#" title=""><span>GOOGLE EARTH</span></a></li>
</ul>
</div>
</div>
Basically i can't get #panelGallery to have an 'auto' width in IE6/7 (works fine in all other)
CSS
#panelGallery {
background-color: #333;
color: #FFFFFF;
float: right;
font-size: 11px;
font-weight: bold;
height: 65px;
line-height: 65px;
opacity: 0.9;
/*width: 640px;*/
position:absolute;
bottom: 0px;
right:0px;
}
.contSlideGalleryDown {
position:absolute;
bottom: 65px;
right:0;
}
And i add this hack for ie6/7
#panelGallery {
*width: auto !important;
}
But still uses all width
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来 IE 使用 Quirks 模式,因为我确信 IE6/IE7 支持
width:auto
。您可以在下面插入书签来检测渲染模式。CSS1Compat
表示标准模式和BackCompat
Quirks 模式。如果它显示
BackCompat
,则意味着 IE 在之前看到过某些内容。如果 IE 6 和 7 在 DOCTYPE、BOM 标记或 HTML 注释计入之前看到几乎任何内容,则使用 Quirks 模式。
已经有一些关于它的问题,所以我将链接到它: 为什么网站以 IE 怪异模式运行?
顺便说一句,http://validator.nu/< /a> 可以使用注释或 BOM 标记检测网站是否会触发 IE 中的 Quirks 模式。
此外,某些
DOCTYPE
可以触发 Quirks 模式,即使之前没有任何内容可以触发 Quirks 模式。 http://hsivonen.iki.fi/doctype/ 包含那些特殊DOCTYPE 的列表
。It looks like IE uses Quirks Mode, because I'm sure that IE6/IE7 have support for
width:auto
. You can insert bookmarklet below to detect rendering mode.CSS1Compat
means Standards Mode andBackCompat
Quirks Mode.If it shows
BackCompat
that means that IE seen something before<!DOCTYPE>
. IE 6 and 7 uses Quirks Mode if it sees nearly anything before DOCTYPE, BOM mark or HTML comment counts into it.There is already some question about it, so I will just link to it: Why is the site running in IE quirks mode?
By the way, http://validator.nu/ can detect if site would trigger Quirks Mode in IE by using either comments or BOM mark.
Also, some
DOCTYPE
s can trigger Quirks Mode even if there is nothing before them can trigger Quirks Mode. http://hsivonen.iki.fi/doctype/ contains list of those specialDOCTYPE
s.您是否尝试过使用条件语句而不是星号黑客?
像这样的东西:
Have you tried to use the conditional statement rather than a star hack?
Something like: