【问题标题】:When hover inside circle(yellow) outside border (height and width) need to be increased (animate) from center and circle in same position?当悬停在圆圈(黄色)内时,边界外(高度和宽度)需要从中心增加(动画)并在同一位置圆圈?
【发布时间】:2017-07-19 08:55:45
【问题描述】:

当鼠标悬停在圆形(黄色)内时,边框(高度和宽度)需要从中心增加(动画),圆形(黄色)在边框内的中心位置

{
  background-color: yellow;
  border-radius: 50%;
  border: 1px solid grey;
  padding: 10px;
}

.circle {
  position: absolute;
  border: 5px solid #000;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  transition: width 0.5s, height 0.5s;
}

.circle:hover {
  width: 60px;
  height: 60px;
}
<div class="circle">
  <span><a><i class="icon_social fa fa-facebook-square"></i></a></span>
</div>

【问题讨论】:

    标签: javascript html css jquery-ui css-transitions


    【解决方案1】:

    你可以写 css 即

     
    
    html {
      -moz-box-sizing: border-box;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }
    *, *:before, *:after {
      -moz-box-sizing: inherit;
      -webkit-box-sizing: inherit;
      box-sizing: inherit;
    }
    .circle {
      border-radius: 50%;
      height: 40px;
      margin-top: 20px;
      position: relative;
      transition: all 0.5s ease 0s;
      width: 40px;
    }
    .circle::before {
      border: 4px solid #000;
      border-radius: 50%;
      bottom: 0;  
      content: "";
      height: 100%;
      left: 0;
      margin: auto;
      position: absolute;
      right: 0;
      top: 0;
      -webkit-transition: all 0.5s ease 0s;
      transition: all 0.5s ease 0s;
      width: 100%;
    }
    .circle:hover::before {
      -webkit-transform: scale(1.2);
      transform: scale(1.2);
    }
    .circle span {
      display: block;
      height: 100%;
      text-align: center;
      vertical-align: middle;
      width: 100%;
    }
    .circle a {
      left: 50%;
      margin: auto;
      position: absolute;
      text-align: center;
      top: 50%;
      transform: translate(-50%, -50%);
    }
    i {
      background-color: yellow;
      border: 1px solid grey;
      border-radius: 50%;  
      display: block;
      padding: 10px;
      text-align: center;
      vertical-align: middle;
    }
    <div class="circle">
      <span><a><i class="icon_social fa fa-facebook-square"></i></a></span>
    </div>

    【讨论】:

      【解决方案2】:

      它可以帮助你..!

      * {box-sizing: border-box;}
      .holder {position: relative; display: inline-block; padding: 10px; border-radius: 50%; margin: 100px;}
      .circle {position: absolute; top: 0px; left: 0px; border: solid 5px #000; width: 100%; height: 100%; border-radius: 50%; transition: all 0.3s ease;}
      i {background: yellow; padding: 10px; border-radius: 50%;}
      .circle:hover {transform: scale(1.2);}
      <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
      <div class="holder">
      	<i class="fa fa-facebook-square"></i>
      	<div class="circle"></div>
      </div>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-11-12
        • 2023-01-30
        • 2014-11-16
        • 2023-03-22
        • 2011-09-24
        • 2019-05-09
        • 2013-03-17
        相关资源
        最近更新 更多