Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

css小猫笑起来的动画 #4

Open
xiaotiandada opened this issue Jan 19, 2021 · 0 comments
Open

css小猫笑起来的动画 #4

xiaotiandada opened this issue Jan 19, 2021 · 0 comments

Comments

@xiaotiandada
Copy link
Owner

2018-06-05 13:39:54

No.3 - CSS transition 和 CSS transform 配合制作动画

仓库地址

预览地址

资料

文章地址

其实文章地址里面提供的资料已经很不错了!!!(偷懒~

效果

截图

截图

代码实现

# html
<div class="container">
  <!-- 脸 -->
  <div class="face">
    <!-- 头发 -->
    <div class="hair"></div>
    <!-- 眼睛 -->
    <div class="eye-wrap">
      <div class="eye left">
        <div class="eye-circle">
          <div class="eye-core"></div>
        </div>
        <div class="eye-bottom"></div>
        <div class="face-red"></div>
      </div>
      <div class="eye right">
        <div class="eye-circle">
          <div class="eye-core"></div>
        </div>
        <div class="eye-bottom"></div>
        <div class="face-red"></div>
      </div>
    </div>
    <!-- 鼻子 -->
    <div class="nose"></div>
    <!-- 嘴巴 -->
    <div class="mouth-wrap">
      <div class="mouth left"></div>
      <div class="mouth right"></div>
    </div>
  </div>
  <!-- 耳朵 -->
  <div class="ear-wrap">
    <div class="ear left"></div>
    <div class="ear right"></div>
  </div>
</div>
# css 动画部分样式
.face,
.hair,
.face-red,
.eye-bottom,
.ear,
.eye-core,
.mouth{
    transition: transform 1s;    
}
.face-red{
    transition: opacity 1s;
}
.mouth{
    transition: border-radius 1s;
}

.face:hover~.ear-wrap .left{
    transform-origin: 50%, 100%;
    transform: rotate(-30deg);
}
.face:hover~.ear-wrap .right{
    transform-origin: 50%, 100%;
    transform: rotate(30deg);
}
.face:hover .eye-wrap .eye-bottom{
    transform: translateY(-15px);
}

.face:hover .eye-wrap .face-red{
    opacity: 1;
}
.face:hover .eye-wrap .eye-core{
    transform: scaleX(.8);
}
.face:hover .mouth-wrap .left{
    border-radius: 0% 40% 50% 50%;
}
.face:hover .mouth-wrap .right{
    border-radius: 0% 40% 50% 50%;
}
.face:hover{
    transform: scaleX(.99);
    transform: translateY(-6px);
}
.face:hover .hair{
    transform: scaleX(.9);
}

Qq: 952822399

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant