【问题标题】:How to create a circle hover reveal when hovering over a picture悬停在图片上时如何创建圆形悬停显示
【发布时间】:2021-06-30 14:07:19
【问题描述】:

当您将鼠标悬停在 png 上时,我会尝试创建悬停动画,该 png 是在其后面显示一个圆圈的 at 图标。但我无法完成这个。我认为你需要在:before:after 标签的帮助下做到这一点,但我不确定。我在互联网上找不到任何好的提示。所以也许你们中的一个可以帮助我。 动画应该是这样的 您从白色的 png a at 图标开始 当您将鼠标悬停在 png 上时,应该会在 png 后面长出一个圆圈

start state

build up

full revealed

已经感谢您的帮助!

【问题讨论】:

    标签: html css animation hover css-animations


    【解决方案1】:

    这是使用 ::before 元素的解决方法。

    HTML:

    <div class="img-wrapper">
        <img src="Screenshot_2.png" alt="">
    </div>
    

    CSS:

    .img-wrapper {
        display: inline-block;
        position: relative;
    }
    .img-wrapper::before {
        position: absolute;
        background: #000;
        width: 100%;
        height: 100%;
        content: "";
        z-index: 1;
        padding: 20px;
        left: -20px;
        top: -20px;
        border-radius: 50%;
        transition: .5s;
        opacity: 0;
        visibility: hidden;
    }
    .img-wrapper img {
        z-index: 2;
        position: relative;
        display: block;
    }
    .img-wrapper:hover::before {
        opacity: 1;
        visibility: visible;
    }
    

    谢谢

    【讨论】:

      【解决方案2】:

      HTML:

      &lt;div class="icon"&gt;@&lt;div&gt;

      CSS:

      .icon::after {
        content: "";
        position: absolute;
        left: 0px;                 /* adujust this value */
        top: 2px;                  /* adujust this value */
        width: 2rem;               /* adujust this value */
        height: 2rem;              /* adujust this value */
        transform: scale(0);
        border-radius: 50%;
        z-index: -1;
        background-image: linear-gradient(
          to top right,
          rgb(25, 68, 255),
          rgb(0, 162, 255)
        );
        transition: all 0.2s ease-out;
      }
      
      .icon:hover::after {
        transform: scale(1);
      }
      

      【讨论】:

        猜你喜欢
        • 2017-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-19
        • 2017-07-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-19
        相关资源
        最近更新 更多