gpt4 book ai didi

html - css hover 上的负边距导致抖动

转载 作者:搜寻专家 更新时间:2023-10-31 08:32:41 26 4
gpt4 key购买 nike

我希望这个按钮在悬停时有一个边框(如 fiddle 所示)。它实际上做了我想让它做的事,但它在 Chrome 和 Firefox 上抖动太多(IE10 似乎工作得很好)。

这是什么原因,我怎样才能找到一个在过渡期间不会抖动的解决方案?


HTML:

<div id="container">
<div class="round_bt_container">
<div class="round_bt" style="background-image:url(http://edinhopiscinas.com.br/img/img1.png);background-size:160px;background-position:center center;background-repeat:no-repeat;">

</div>
</div>
</div>

CSS:

#container{
width:80%;
height:80%;
position:absolute;
padding:10%;
background-image:url(http://edinhopiscinas.com.br/img/bg.jpg);
}
.round_bt_container{
cursor:pointer;
position:relative;
float:left;
margin-right:40px;
border-radius:50%;
border:5px solid #ffffff;
box-shadow:2px 1px 15px -9px #000000;
width:160px;
height:160px;
-webkit-transition:all 0.2s ease;
-ms-transition: all 0.2s ease;
-moz-transition:all 0.2s ease;
-o-transition:all 0.2s ease;
transition:all 0.2s ease;
}

.round_bt{
position:absolute;
border-radius:50%;
width:160px;
height:160px;
padding:0;
margin:0;
border:0px solid #eeeeee;
-webkit-transition:all 0.2s ease;
-ms-transition: all 0.2s ease;
-moz-transition:all 0.2s ease;
-o-transition:all 0.2s ease;
transition:all 0.2s ease;
}

.round_bt img{
border-radius:50%;
}

.round_bt_container:hover .round_bt{
width:160px;
height:160px;
border:5px solid #f98523;
padding:15px;
margin-left:-20px;
margin-top:-20px;
}

.round_bt_container:hover{
border:2px solid #ffcfa7;
margin-left:3px;
margin-top:3px;
}

最佳答案

将环与图像本身分开:

HTML

<div id="container">
<div class="round_bt_container">
<div class="inner_ring"></div>
<div class="round_bt" style="background-image:url(http://edinhopiscinas.com.br/img/img1.png);background-size:160px;background-position:center center;background-repeat:no-repeat;"></div>
<div class="ring"></div>
</div>
</div>

CSS

.ring {
position:absolute;
border-radius:50%;
width:160px;
height:160px;
padding:0;
margin:0;
border:0px solid #eeeeee;
-webkit-transition:all 0.2s ease;
-ms-transition: all 0.2s ease;
-moz-transition:all 0.2s ease;
-o-transition:all 0.2s ease;
transition:all 0.2s ease;
}

.round_bt_container:hover .ring{
width:160px;
height:160px;
border:5px solid #f98523;
padding:15px;
margin-left:-20px;
margin-top:-20px;
}

http://jsfiddle.net/zcPVj/22/

编辑:我添加了第二个戒指

关于html - css hover 上的负边距导致抖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19520416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com