【问题标题】:Google Chrome position:fixed border-radius overflow:hidden issue谷歌浏览器位置:修复边界半径溢出:隐藏问题
【发布时间】:2013-04-21 04:08:15
【问题描述】:

我在使用带有overflow:hiddenposition:fixed 元素上使用border-radius 时遇到了Google Chrome 问题。 overflow 属性似乎不起作用。当您将鼠标悬停在导航项上时,带有红色背景 .bmoptdiv 应该被裁剪为 #mstrip 的形状,但它只是显示为标准矩形。

HTML:

<div id='mstrip'>
    <div class='mlabel first'>
        <a href='#' class='mopt'>Item1</a>
        <div class='bmopt'></div>
    </div>
    <div class='mlabel'>
        <a href='#' class='mopt'>Item2</a>
        <div class='bmopt'></div>
    </div>
    <div class='mlabel'>
        <a href='#' class='mopt'>Item3</a>
        <div class='bmopt'></div>
    </div>
    <div class='mlabel'>
        <a href='#' class='mopt'>Item4</a>
        <div class='bmopt'></div>
    </div>
    <div class='mlabel'>
        <a href='#' class='mopt'>Item5</a>
        <div class='bmopt'></div>
    </div>
</div>

CSS:

#mstrip {
    width: 92px;
    height: 223px;
    position: fixed;
    top: 20px;
    border-radius: 40% 8px;
    z-index: 100;
    background: #000;
    overflow: hidden;
    box-shadow: 0 0 4px #000;
}
.mlabel {
    width: 92px;
    height: 35px;
}
.first {
    margin-top: 24px;
}
.mopt {
    display: block;
    width: 92px;
    height: 29px;
    padding-top: 6px;
    text-align: center;
    color: #FFF;
    text-decoration: none;
    font: menu;
    font-size: 0.9em;
    text-shadow: 0 0 1px #FFF;
}
.bmopt {
    position: relative;
    width: 92px;
    height: 35px;
    background: #F00;
    margin-top: -35px;
    z-index: -1;
}

这里是这个错误的一个工作示例:http://jsfiddle.net/UxLHR/7/

有没有办法解决这个问题?

【问题讨论】:

    标签: google-chrome overflow css-position css


    【解决方案1】:

    我认为问题出在改变元素的不透明度;这会创建一个单独的堆栈上下文,并且可能是该错误的根源。

    我已经解决了它,让它变得更简单;只需在悬停时更改 mlabel 类的颜色,并在此设置过渡。我不认为内部 div 是必要的。

    .mlabel {
        width: 92px;
        height: 35px;
        background-color: black;
        -webkit-transition: background-color 1s;
    }
    .mlabel:hover {
        background-color: red;
    }
    

    updated fiddle

    (仅适用于 webkit 的转换)

    【讨论】:

    • 我使用的是 Chrome 26,但这并不能解决问题。事实上,它看起来比原版更糟糕。
    • 我在 Chrome 26.0.1410.64 m 中,它对我有用。但我发现我正在使用缩放 90%。当我将缩放设置为 90% 时,它可以工作,当缩放为 100% 时,它不起作用。很奇怪
    猜你喜欢
    • 1970-01-01
    • 2014-11-29
    • 1970-01-01
    • 2011-10-06
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    相关资源
    最近更新 更多