无法在 Chrome 或 Firefox 中删除超链接 IMG 的边框(在 IE8 中工作)

发布于 2024-12-13 05:13:53 字数 4287 浏览 3 评论 0原文

我在母版页上使用 jquery 菜单,并且该菜单是使用无序列表构建的。每个里里面都有一个锚标签。在这个锚标记内,有一个图像标记和几个跨度。

现在,菜单的工作方式是,您只能看到文本(没有边框或背景颜色),直到您将鼠标悬停在列表项上,此时图像和跨度展开并变得可见。一切都运行良好,所有内容都按照 IE8 中应有的方式显示,但是当我在 Chrome 或 Firefox 中运行该网站时,每个列表项都显示一个细灰色框。虽然这看起来不错,但这不是我想要的效果。我认为这与锚直接相关,但标准 CSS 技巧都不起作用。我尝试从其中一个列表项中删除锚标记,果然,该列表项的边框消失了。不幸的是,我需要那里的超链接。 img 标签有一个 src 属性,它被定义并拉出正确的图像。在 CSS 中(我在 site.master 页面的 HEAD 中,我为“a”、“a img”、“a span”设置了以下属性:

        text-decoration:none;
        border-style:none;
        border:none;
        outline:none;

我还尝试直接将 border="0" 添加到IMG,但我唯一一次看到边框消失是当我删除锚标签时,

非常感谢任何帮助,只是为了方便起见

,这是菜单项之一。看起来像代码:

<ul id="sdt_menu" class="sdt_menu">
            <li>
                <a href="#">
                    <img src="images/1.jpg" border="0" alt=""/>
                    <span class="sdt_active"></span>
                    <span class="sdt_wrap">
                        <span class="sdt_link">the island</span>
                        <span class="sdt_descr">About</span>
                    </span>
                </a>
                <div class="sdt_box">
                        <a href="#">Airlines</a>
                        <a href="#">Travel Info</a>
                        <a href="#">Currency</a>
                </div>
            </li>

这是样式表:

ul.sdt_menu
{
    position: absolute;
    top: 148px;
    margin:0;
    padding:0;
    list-style: none;
    font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
    font-size:14px;
    width:968px;
    border: 0px;
}
ul.sdt_menu a{
    text-decoration:none;
    outline:none;
    border: 0px;
}
ul.sdt_menu li{
    float:left;
    width:161px;
    height:85px;
    position:relative;
    cursor:pointer;
    text-decoration:none;
    outline:none;
    border:0px;
}
ul.sdt_menu li > a{
    position:absolute;
    top:0px;
    left:0px;
    width:161px;
    height:85px;
    z-index:12;
    -moz-box-shadow:0px 0px 2px #000 inset;
    -webkit-box-shadow:0px 0px 2px #000 inset;
    box-shadow:0px 0px 2px #000 inset;
    text-decoration:none;
    outline:none;
    border:0px;
}
ul.sdt_menu li a img{
    border:none;
    text-decoration:none;
    outline:none;
    position:absolute;
    width:0px;
    height:0px;
    bottom:0px;
    left:85px;
    z-index:100;
    -moz-box-shadow:0px 0px 4px #000;
    -webkit-box-shadow:0px 0px 4px #000;
    box-shadow:0px 0px 4px #000;
}
ul.sdt_menu li span.sdt_wrap{
    position:absolute;
    top:25px;
    left:0px;
    width:161px;
    height:60px;
    z-index:15;
    border:none;
    text-decoration:none;
    outline:none;
}
ul.sdt_menu li span.sdt_active{
    position:absolute;
    background:#111;
    top:85px;
    width:161px;
    height:0px;
    left:0px;
    z-index:14;
    -moz-box-shadow:0px 0px 4px #000 inset;
    -webkit-box-shadow:0px 0px 4px #000 inset;
    box-shadow:0px 0px 4px #000 inset;
    border:none;
    text-decoration:none;
    outline:none;
}
ul.sdt_menu li span span.sdt_link,
ul.sdt_menu li span span.sdt_descr,
ul.sdt_menu li div.sdt_box a{
    margin-left:15px;
    text-transform:uppercase;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li span span.sdt_link{
    color:#333333;
    font-size:24px;
    float:left;
    clear:both;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li span span.sdt_descr{
    color:#0066FF;
    float:left;
    clear:both;
    width:155px; /*For dumbass IE7*/
    font-size:12px;
    letter-spacing:1px;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box{
    display:block;
    position:absolute;
    width:161px;
    overflow:hidden;
    height:161px;
    top:85px;
    left:0px;
    display:none;
    background:#000;
    z-index:100;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box a{
    float:left;
    clear:both;
    line-height:30px;
    color:#0066FF;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box a:first-child{
    margin-top:5px;
}
ul.sdt_menu li div.sdt_box a:hover{
    color:#666666;
}

I am using a jquery menu on a Master page, and the menu is built with a Unordered List. Inside each li, there is anchor tag. Inside this anchor tag, there is an image tag and a couple spans.

Now, the way the menu works is that you just see text (no borders or background colors) until you hover over the listitem, at which point the image and spans expode out and become visible. Everything is working great, and everything displays exactly as it should in IE8, but when I run the site in Chrome or Firefox, each listitem is displayed with a thin gray box. While this looks ok, it is not my desired effect. I assume that this is directly related to the anchor, but none of the standard CSS tricks are working. I have tried removing the anchor tag from one of the list items, and sure enough, the border is gone for that listitem. Unfortunately, I need that hyperlink there. The img tags have a src attribute, and it is defined and pulling the correct image. In the CSS (which I have in the HEAD of the site.master page, I have the following attributes set for "a", "a img", "a span":

        text-decoration:none;
        border-style:none;
        border:none;
        outline:none;

I have also tried adding border="0" directly to the IMG, but no luck at all. The only time I have seen that border disappear is when I remove the anchor tags.

I am stuck on this. Any help is greatly appreciated!

Just for ease, here is what one of the menu items looks like in code:

<ul id="sdt_menu" class="sdt_menu">
            <li>
                <a href="#">
                    <img src="images/1.jpg" border="0" alt=""/>
                    <span class="sdt_active"></span>
                    <span class="sdt_wrap">
                        <span class="sdt_link">the island</span>
                        <span class="sdt_descr">About</span>
                    </span>
                </a>
                <div class="sdt_box">
                        <a href="#">Airlines</a>
                        <a href="#">Travel Info</a>
                        <a href="#">Currency</a>
                </div>
            </li>

And here is the Style Sheet:

ul.sdt_menu
{
    position: absolute;
    top: 148px;
    margin:0;
    padding:0;
    list-style: none;
    font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
    font-size:14px;
    width:968px;
    border: 0px;
}
ul.sdt_menu a{
    text-decoration:none;
    outline:none;
    border: 0px;
}
ul.sdt_menu li{
    float:left;
    width:161px;
    height:85px;
    position:relative;
    cursor:pointer;
    text-decoration:none;
    outline:none;
    border:0px;
}
ul.sdt_menu li > a{
    position:absolute;
    top:0px;
    left:0px;
    width:161px;
    height:85px;
    z-index:12;
    -moz-box-shadow:0px 0px 2px #000 inset;
    -webkit-box-shadow:0px 0px 2px #000 inset;
    box-shadow:0px 0px 2px #000 inset;
    text-decoration:none;
    outline:none;
    border:0px;
}
ul.sdt_menu li a img{
    border:none;
    text-decoration:none;
    outline:none;
    position:absolute;
    width:0px;
    height:0px;
    bottom:0px;
    left:85px;
    z-index:100;
    -moz-box-shadow:0px 0px 4px #000;
    -webkit-box-shadow:0px 0px 4px #000;
    box-shadow:0px 0px 4px #000;
}
ul.sdt_menu li span.sdt_wrap{
    position:absolute;
    top:25px;
    left:0px;
    width:161px;
    height:60px;
    z-index:15;
    border:none;
    text-decoration:none;
    outline:none;
}
ul.sdt_menu li span.sdt_active{
    position:absolute;
    background:#111;
    top:85px;
    width:161px;
    height:0px;
    left:0px;
    z-index:14;
    -moz-box-shadow:0px 0px 4px #000 inset;
    -webkit-box-shadow:0px 0px 4px #000 inset;
    box-shadow:0px 0px 4px #000 inset;
    border:none;
    text-decoration:none;
    outline:none;
}
ul.sdt_menu li span span.sdt_link,
ul.sdt_menu li span span.sdt_descr,
ul.sdt_menu li div.sdt_box a{
    margin-left:15px;
    text-transform:uppercase;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li span span.sdt_link{
    color:#333333;
    font-size:24px;
    float:left;
    clear:both;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li span span.sdt_descr{
    color:#0066FF;
    float:left;
    clear:both;
    width:155px; /*For dumbass IE7*/
    font-size:12px;
    letter-spacing:1px;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box{
    display:block;
    position:absolute;
    width:161px;
    overflow:hidden;
    height:161px;
    top:85px;
    left:0px;
    display:none;
    background:#000;
    z-index:100;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box a{
    float:left;
    clear:both;
    line-height:30px;
    color:#0066FF;
    text-decoration:none;
    outline:none;
    border:none;
}
ul.sdt_menu li div.sdt_box a:first-child{
    margin-top:5px;
}
ul.sdt_menu li div.sdt_box a:hover{
    color:#666666;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

送君千里 2024-12-20 05:13:53

感谢您发布样式表。您看到的灰色“边框”来自此规则:

ul.sdt_menu li > a {
  -moz-box-shadow:0px 0px 2px #000 inset;
  -webkit-box-shadow:0px 0px 2px #000 inset;
  box-shadow:0px 0px 2px #000 inset;
}

根据 http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx IE 没有直到 IE9 才添加 box-shadow 支持,这就是为什么在 IE8 中看不到阴影。

Thanks for posting the stylesheet. That gray "border" you're seeing is from this rule:

ul.sdt_menu li > a {
  -moz-box-shadow:0px 0px 2px #000 inset;
  -webkit-box-shadow:0px 0px 2px #000 inset;
  box-shadow:0px 0px 2px #000 inset;
}

According to http://msdn.microsoft.com/en-us/library/cc351024%28v=vs.85%29.aspx IE didn't add box-shadow support until IE9, which is why you don't see the shadow in IE8.

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