css - 动画问题正在干扰子元素

标签 css

我想缩放作为 h6 子级的跨度。但是在某个地方它影响了我的跨度,它在跨度内。

<style>
.block {
margin-top: 0;
padding: 0;
background: #39b4bf;
}

.block h6 {
border: 3px solid #fff;
display: inline-block;
border-radius: 50%;
margin: 0 0 50px;
padding: 25px;
height: 215px;
width: 212px;
position: relative;
transition: all .3s;
overflow: hidden;
box-sizing: border-box;
}

.block h6 > span {
color: #39b4bf;
font-size: 34px;
background: #74cad2;
padding: 54px 54px;
border-radius: 50%;
display: inline-block;
border: 25px solid #39b4bf;
}

.block h6 > span > span {
position: absolute;
color: #39b4bf;
font-size: 34px;
background: #fff;
padding: 36px 20px;
border-radius: 50%;
display: inline-block;
left: 50px;
top: 49px;
}

.block h6:hover {
  border-color: #74cad2;
  /*animation: border .3s cubic-bezier(.32,1.63,.44,1.82);*/
}

.block h6:hover > span {
  border-color: #74cad2;
  animation: bordereffect .6s;
}

@-webkit-keyframes bordereffect {
0%   {
  -webkit-transform: scale(1);

}
50%  {
  -webkit-transform: scale(1.5);

}
100% {
  -webkit-transform: scale(1);

}
}
</style>
<div class="col-md-5 block block-one text-center">
          <h6>
            <span><span><strong class="fig-number">27</strong>%</span></span>
          </h6>
          <p>
            <span>Employer said</span>
            a bad hire cost them more than $50,000
          </p>
        </div>

最佳答案

您可以使这些 span 成为 sibling (未嵌套)并将样式应用于 h6:first-child:last-child/p>

.block {
margin-top: 0;
padding: 0;
background: #39b4bf;
}

.block h6 {
border: 3px solid #fff;
display: inline-block;
border-radius: 50%;
margin: 0 0 50px;
padding: 25px;
height: 215px;
width: 212px;
position: relative;
transition: all .3s;
overflow: hidden;
box-sizing: border-box;
}

.block h6 span:first-child {
color: #39b4bf;
font-size: 34px;
background: #74cad2;
padding: 54px 54px;
border-radius: 50%;
display: inline-block;
border: 25px solid #39b4bf;
}

.block h6 span:last-child {
position: absolute;
color: #39b4bf;
font-size: 34px;
background: #fff;
padding: 36px 20px;
border-radius: 50%;
display: inline-block;
left: 50px;
top: 49px;
}

.block h6:hover {
  border-color: #74cad2;
  /*animation: border .3s cubic-bezier(.32,1.63,.44,1.82);*/
}

.block h6:hover span:first-child {
  border-color: #74cad2;
  animation: bordereffect .6s;
}

@-webkit-keyframes bordereffect {
0%   {
  -webkit-transform: scale(1);

}
50%  {
  -webkit-transform: scale(1.5);

}
100% {
  -webkit-transform: scale(1);

}
}
<div class="col-md-5 block block-one text-center">
          <h6>
              <span></span>
              <span><strong class="fig-number">27</strong>%</span>
          </h6>
          <p>
            <span>Employer said</span>
            a bad hire cost them more than $50,000
          </p>
        </div>

关于css - 动画问题正在干扰子元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42156867/

相关文章:

html - 在网页上居中图像

css - angular-ui-grid 无法在嵌套的 ui-view 中正确呈现

javascript - 获取点击它的导航项的名称

html - 覆盖溢出 :hidden with z-index

html - 悬停时如何将所有元素保持在顶部

jquery - 部分 Jquery "hide/show"工作,其他部分不工作

iOS 上出现的 CSS 背景线

javascript - 返回顶部按钮不起作用

php - 以编程方式从php数组创建具有不同背景颜色的div

javascript - jQuery .css() 中的 CSS 框阴影