繁体   English   中英

safari / chrome中的圆角在悬停第一秒时不会圆滑

[英]Rounded corners in safari/chrome are not rounded on hover for first second

我有Safari / Chrome的问题。 在这些浏览器上(悬停时),我的圆角形成一个正方形,然后返回圆形。 这是代码

CSS
    div.img-cont {
            float:left; 
            position:relative; 
            margin:10px 20px 0 0px;
            width:180px; 
            height:160px;    
            border:0px solid #FFF;
            overflow:hidden !important;
             -webkit-border-radius:5px; 
                -moz-border-radius:5px; 
                 -ms-border-radius:5px;
                  -o-border-radius:5px; 
                     border-radius:5px;            
    } 
    div.img-zoom { 
            float:left; 
            position:relative; 
            margin:-20px 0 0 -20px; 
            width:220px; 
            height:200px;
            background-position:center center !important;
            -webkit-transition: all 0.25s ease-in-out;
               -moz-transition: all 0.25s ease-in-out;
                -ms-transition: all 0.25s ease-in-out;
                 -o-transition: all 0.25s ease-in-out;
                    transition: all 0.25s ease-in-out;
    } 
    .transition {
            -webkit-transform: scale(0.93,0.93); 
               -moz-transform: scale(0.93,0.93);
                -ms-transform: scale(0.93,0.93);
                 -o-transform: scale(0.93,0.93);
                    transform: scale(0.93,0.93);    
    } 
    .f_border{
             -webkit-border-radius:5px; 
                -moz-border-radius:5px; 
                 -ms-border-radius:5px;
                  -o-border-radius:5px; 
                     border-radius:5px;  
    }

HTML

       <div class="Box_1x1_front" style="height:180px; background:#eaeaea; ">
            <a class="leftAllPlace" rel="thumb" title="" href="http://bonavestis.pl/image/cache/data/Produkty/Sukienki/Sukienka%20JUST%20UNIQUE%20Bandażowa%20W%20Beżu%20+Złoto/Image001-885x885.jpg">
                <div class="img-cont f_border">
                    <div class="img-zoom img_2">
                        <div style="float:left; width:100%; height:100%; background-image:url('http://bonavestis.pl/image/cache/data/Produkty/Sukienki/Sukienka%20JUST%20UNIQUE%20Bandażowa%20W%20Beżu%20+Złoto/Image001-372x372.jpg');"></div>
                    </div>
                </div>
            </a>
        </div>

JAVASCRIPT HERE

    <script>
    $(document).ready(function(){
        $('.img_2').hover(function() {
            $(this).addClass('transition');
        }, function() {
            $(this).removeClass('transition');
        });
    });
    </script>

它喜欢缩小div与背景图像div内圆角任何想法如何解决这个问题...

[1]: http://jsfiddle.net/Lqfmdah5/6/

在JavaScript中应用的转换会消除CSS border-radius 以下方法更清晰,意味着您不需要使用JavaScript:

HTML

<div class="rounded-box">
</div>

CSS

.rounded-box {
    display: block;
    width: 100px;
    height: 100px;
    background: url(http://bit.ly/1MjBCE6) no-repeat center;
    background-size: 100px 100px;
    transition: background-size 0.2s ease-in;
    border-radius: 5px;
}
.rounded-box:hover {
   background-size: 200px 200px;
}

1)

正如@Squideyes所提到的,如何添加转换只有一种CSS方法。

只需添加CSS选择器:

.img_2:hover {

}

而不是.transition

2)

另外,我建议在你的情况下使用<img>而不是<div>background-images ,因为从我的观点来看,这里的图像是一个内容部分元素,并假设使用<img>

更多信息: IMG与背景图像

3)

关于Chrome中的scale问题。 似乎Webkit中存在transitionborder-radious的故障。 尝试更改widthheight作为变通方法。

查看https://jsfiddle.net/Lqfmdah5/7/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM