4

我遇到的问题是通过 jQuery 应用 css 属性时border-radiusa<div/>被删除。具有半径的 也正在裁剪width定位的。我在下面包含了一个示例:<div/>absolute<div/>

http://jsfiddle.net/SLvBZ/2/

这是一个适用于 Twitter 的类似示例(先登录): https ://twitter.com/welcome/recommendations

浏览器版本:Chrome 26.0.1410.65

#SuggestProgressContainer {
    height: 27px;
    float: left;
    margin: 4px 20px 0 0;
    position: relative; top: 0; left: 0;
    width: 247px;
    overflow: hidden;

    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
}

#SuggestProgressBar {
    width: 247px;
    height: 27px;
    background: #c6c6c6;
    border: 1px solid #bfbfbf;
    position: absolute; top: 0; left: 0;
}

#SuggestProgress {
    height: 100%;
    width: 50px;
    position: absolute; top: 0; left: 0;
    border: 1px solid #068CE1;
    background: #0F93E7;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1c9dee), to(#068ce1));
    background: -webkit-linear-gradient(top, #1c9dee, #068ce1);
    background: -moz-linear-gradient(top, #1c9dee, #068ce1);
    background: -ms-linear-gradient(top, #1c9dee, #068ce1);
    background: -o-linear-gradient(top, #1c9dee, #068ce1);

    -webkit-transition: width 230ms ease-out;
       -moz-transition: width 230ms ease-out;
        -ms-transition: width 230ms ease-out;
         -o-transition: width 230ms ease-out;
            transition: width 230ms ease-out;
}

#ProgressText {
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 -1px rgba(0,0,0, .15);
}
4

1 回答 1

2

webkit(或至少 Chrome)中存在一个错误,其中包含border-radius,overflow: hidden和. 您在 twitter 上的示例链接使用静态位置。所以我想说你唯一的选择是使用. 我修改了你的代码来这样做:positionstaticposition: static

<div id="SuggestComplete">
   <div id="SuggestProgressContainer">
       <div id="SuggestProgressBar">
           <div id="SuggestProgress"></div>
       </div>
       <span id="ProgressText">Follow 5 collections</span>
   </div>
</div>

<div id="button">test</div>

CSS:

#SuggestProgressContainer {
    height: 27px;
    float: left;
    margin: 4px 20px 0 0;
    position: relative; top: 0; left: 0;
    width: 247px;
    /*overflow: hidden;

    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;*/ /* removed here */
}

#SuggestProgressBar {
    width: 247px;
    height: 27px;
    background: #c6c6c6;
    border: 1px solid #bfbfbf;
    position: absolute; top: 0; left: 0;

    /* added overflow and border radius here */
    overflow: hidden;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
}

#SuggestProgress {
    height: 100%;
    width: 50px;
    /*position: absolute; top: 0; left: 0;*/ /* so it is static to prevent the bug */
    border: 1px solid #068CE1;
    background: #0F93E7;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1c9dee), to(#068ce1));
    background: -webkit-linear-gradient(top, #1c9dee, #068ce1);
    background: -moz-linear-gradient(top, #1c9dee, #068ce1);
    background: -ms-linear-gradient(top, #1c9dee, #068ce1);
    background: -o-linear-gradient(top, #1c9dee, #068ce1);

    -webkit-transition: width 230ms ease-out;
       -moz-transition: width 230ms ease-out;
        -ms-transition: width 230ms ease-out;
         -o-transition: width 230ms ease-out;
            transition: width 230ms ease-out;
}

这似乎有效。这是一个演示

有趣的是,错误报告中描述的问题似乎已得到修复,因为当时即使没有以编程方式更改width. 但看起来他们也忘了解决重新渲染事件的问题。

于 2013-05-20T21:00:39.390 回答