2025年9月4日木曜日

[CSS]画像をふわふわさせるフローティングアニメーション

この前ドラえもんが浮いてるのを見て合ってるなと

コードはそこからパクってきたわけではないですが

HTML

   <div class="floating">
     <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4LBYWOQnPDoF2PkqAvvxBzOJyrn3JkhU4JVQso-rXAlZa1CJ_4LeekGppdjRrmKdQHTSiknbs8X_PimAjQqqVsTZJWPOFBhYjWeK-ThnjWE3LNmui_txLaeKhMRoQk_VW2J1sHUNvBfiq7JuZWwKWilOsvZBANAGZzEf4jZXfJfCguOMrNtqj8r9LnSat/s0/my-melody-flying.png" style="max-width:100%">
    </div>

CSS

.floating {  
  position: fixed;
  right: 0%;
  top: 0px;
  width: 250px;
  z-index: 33;

  animation-name: floating;
  animation-duration: 3s;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  margin-left: 30px;
  margin-top: 5px;
}

@keyframes floating {
  from { transform: translate(0,  0px); }
  65%  { transform: translate(0, 15px); }
  to   { transform: translate(0, -0px); }    
}

*位置は要調整

結果

右上の方に出ているはず

F(uriouz)

欲しいものリスト / 優先度の高いほしいものリスト / ☕を奢る
Donate 寄付 カンパ サポート Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
詳細プロフィールを表示

0 comments:

スパム対策の為コメントをオフにしています。
Disqusは利用出来ます。

注: コメントを投稿できるのは、このブログのメンバーだけです。

...

Recent Posts

 
"The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License."