LoginSignup
7
7

More than 5 years have passed since last update.

CSSだけでhover時にdiv要素をふわっと浮き上がらせる

Last updated at Posted at 2018-02-28

やりたいこと

マウスオーバー時にdivの要素をふわっと浮きあがらせたい。例えば、カードやボタンなどだ。

実装方法

<a href="#" class="fly">テスト</a>
.fly {
    background-color: #3169d1;
    color: #fff !important;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-transition: all .3s;
    transition: all .3s;
    margin: 10px 0 0 0;
}
.fly:hover {
    -webkit-transform: translateY(-5px);
    -ms-transform: translateY(-5px);
    transform: translateY(-5px);
}

これだけでふわっとした動きをつけることができる。

参考:http://design.aekana.com/blog/css-mouseover-effect

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7