Chrome无法接收CSS圆角边框

时间:2011-12-23 15:35:08

标签: html css html5 css3

我遇到问题让Chrome在我从头开始构建的下拉式导航中显示我的圆角。圆角在Firefox中显示得很好,但Chrome和IE9似乎不想渲染我的角落。我已经将我的圆角调用更改为我下拉列表中的最后一个<li>元素以及我显示为具有宽度和高度属性的块的最后一个<a>,但似乎没有什么可以做的!

所以我想我会在这里发帖,看看是否有人能给我一个正确方向的推动。

该网站仍处于早期开发阶段,因此不必担心冗余的锚链接。

我的HTML:

<nav>
        <ul id="mainNav">
            <li>
                <a href="highlevel.html" class="autos"></a>
                <ul>
                    <li><a href="subcategory.html">News</a></li>
                    <li><a href="subcategory.html">Reviews</a></li>
                    <li><a href="subcategory.html">Car Tech</a></li>
                    <li><a href="subcategory.html">Fuel Economy &amp; Safety</a></li>
                    <li><a href="subcategory.html">Buying &amp; Selling</a></li>
                    <li><a href="subcategory.html">Everything Else</a></li>
                </ul>
            </li>
            <li>
                <a href="highlevel.html" class="lifestyles"></a>
                <ul>
                    <li><a href="subcategory.html">Music</a></li>
                    <li><a href="subcategory.html">Food</a></li>
                    <li><a href="subcategory.html">Travel</a></li>
                    <li><a href="subcategory.html">Shopping</a></li>
                    <li><a href="subcategory.html">Everything Else</a></li>
                </ul>
            </li>
            <li>
                <a href="highlevel.html" class="people"></a>
                <ul>
                    <li><a href="subcategory.html">Who You Know</a></li>
                    <li><a href="subcategory.html">Who You Should Know</a></li>
                    <li><a href="subcategory.html">Everyone Else</a></li>
                </ul>
            </li>
            <li>
                <a href="highlevel.html" class="tech"></a>
                <ul>
                    <li><a href="subcategory.html">Business</a></li>
                    <li><a href="subcategory.html">Pleasure</a></li>
                    <li><a href="subcategory.html">Everything Else</a></li>
                </ul>
            </li>
            <li>
                <a href="highlevel.html" class="trends"></a>
                <ul>
                    <li><a href="subcategory.html">Online</a></li>
                    <li><a href="subcategory.html">Offline</a></li>
                    <li><a href="subcategory.html">Everything Else</a></li>
                </ul>
            </li>
        </ul>
    </nav><!-- /Main Nav -->

我的CSS:

nav {
    display:block;
    position:relative;
    width:980px;
    height:41px;
    background:url(../../images/nav_bg.png) center top no-repeat;
    margin:0 auto;
    border-bottom:2px solid #777;
    z-index:9998;
}

#mainNav {
    display:block;
    position:relative;  
    background:#fff;
}

#mainNav li {
    float:left; 
}

#mainNav li a {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    overflow:hidden;
}

#mainNav li a.autos {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    background:url(../../images/nav1.png) center top no-repeat;
}

#mainNav li a.autos:hover {
    background:url(../../images/nav1.png) center -41px no-repeat;
}

#mainNav li a.lifestyles {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    background:url(../../images/nav2.jpg) center top no-repeat;
}

#mainNav li a.lifestyles:hover {
    background:url(../../images/nav2.jpg) center -41px no-repeat;
}

#mainNav li a.people {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    background:url(../../images/nav3.jpg) center top no-repeat;
}

#mainNav li a.people:hover {
    background:url(../../images/nav3.jpg) center -41px no-repeat;
}

#mainNav li a.tech {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    background:url(../../images/nav4.jpg) center top no-repeat;
}

#mainNav li a.tech:hover {
    background:url(../../images/nav4.jpg) center -41px no-repeat;
}

#mainNav li a.trends {
    display:block;
    position:relative;
    width:125px;
    height:41px;
    background:url(../../images/nav5.jpg) center top no-repeat;
}

#mainNav li a.trends:hover {
    background:url(../../images/nav5.jpg) center -41px no-repeat;
}

/* === Dropdown Menu Styles === */

#mainNav ul {
    display:none;   
    position:absolute;  
    z-index:9998;
}

#mainNav li:hover ul {
    display:block;
    position:absolute;
    width:160px;
    height:auto;
    border-right:1px solid #999;
    border-left:1px solid #999;
    overflow:hidden;

    -moz-border-radius-topleft: 0px;
    -moz-border-radius-topright: 0px;
    -moz-border-radius-bottomright: 7px;
    -moz-border-radius-bottomleft: 7px;
    -webkit-border-radius: 0px 0px 7px 7px;
    border-radius: 0px 0px 7px 7px; 

    -webkit-box-shadow: 0px 5px 3px 0px rgba(0, 0, 0, .25);
    -moz-box-shadow: 0px 5px 3px 0px rgba(0, 0, 0, .25);
    box-shadow: 0px 5px 3px 0px rgba(0, 0, 0, .25); 
}

#mainNav li:hover ul li a {
    display:block;
    width:160px;
    height:auto;
    background:#fff;
    padding:5px 0;
    border-bottom:1px solid #999;

    font-family: 'Swiss721Light', Verdana, Arial;
    text-indent:10px;
    text-decoration:none;
    font-size:14px;
    line-height:16px;
color:#555;
}

#mainNav li:hover ul li a:hover {
    background:#eaeaea;
}

3 个答案:

答案 0 :(得分:5)

你可以这样做:

#mainNav li:hover ul li:last-child a{
    border-radius: 0px 0px 7px 7px;     
}

你还需要摆脱包含ul

上的40px填充

在底部添加填充很好但是看起来有点乱,特别是如果你在各个链接周围使用边框

答案 1 :(得分:2)

Chrome和IE不会隐藏溢出边框半径的内容。您的下拉链接目前设置为background: white;,底部链接溢出圆角边框。因此,链接的白色背景将显示在圆形边框的边缘上。要解决此问题,您可以删除链接的背景或添加填充到下拉列表的底部。另一种选择是在每个下拉列表中设置最后a的边界半径。

Change background:

#mainNav li:hover ul li a {
    background: #fff; /* remove this line */
    border-bottom: ... /* change to border-top */
}

Padding:

#mainNav li:hover ul {
    ...
    padding-bottom: 7px;
}

答案 2 :(得分:1)

这是一个溢出问题..圆角框内的所有元素都需要相同的边框半径

http://jsfiddle.net/pixelass/KZXnT/

#mainNavli > ul > li.last,
#mainNav > li ul > li.last a {
    -moz-border-radius-topleft: 0px;
    -moz-border-radius-topright: 0px;
    -moz-border-radius-bottomright: 7px;
    -moz-border-radius-bottomleft: 7px;
    -webkit-border-radius: 0px 0px 7px 7px;
    border-radius: 0px 0px 7px 7px; 
}