div width auto !important 似乎在 ie6/ie7 中不起作用

发布于 2024-12-04 06:58:28 字数 2959 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不回头走下去 2024-12-11 06:58:28

看起来 IE 使用 Quirks 模式,因为我确信 IE6/IE7 支持 width:auto。您可以在下面插入书签来检测渲染模式。

javascript:alert(document.compatMode)

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.

javascript:alert(document.compatMode)

CSS1Compat means Standards Mode and BackCompat 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 DOCTYPEs can trigger Quirks Mode even if there is nothing before them can trigger Quirks Mode. http://hsivonen.iki.fi/doctype/ contains list of those special DOCTYPEs.

沧桑㈠ 2024-12-11 06:58:28

您是否尝试过使用条件语句而不是星号黑客?

像这样的东西:

<!--[if lte IE 7]>
<style>
#panelGallery {
   width: auto !important;
}

</style>
<![endif]-->

Have you tried to use the conditional statement rather than a star hack?

Something like:

<!--[if lte IE 7]>
<style>
#panelGallery {
   width: auto !important;
}

</style>
<![endif]-->
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文