CSS、HTML勉強中の者です。
現在文字にカーソルを合わせると文字が震えるようなものを作りたいと思っていますが、:hoverをどのようにつかえば文字が震えるのかがわかりませんので、ご教授おねがいします。
HTML
1<body> 2 <div class="content"> 3 <h2 class="hurueru">このテキストを震えさせたい</h2> 4 </div> 5 6</body>
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
ベストアンサー
CSSのみで文字を震えさせるには@keyframesプロパティを利用します。
HTML
1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 <meta charset="utf-8"> 5 <title>タイトル</title> 6 <style type="text/css"> 7 * { 8 margin: 0; 9 padding: 0; 10 } 11 12 .hurueru:hover { 13 -webkit-animation-name: animation; 14 -webkit-animation-duration: .7s; 15 -webkit-animation-iteration-count: infinite; 16 } 17 18 @-webkit-keyframes animation { 19 0% { 20 -webkit-transform: translate(3px, 2px) rotate(0deg); 21 } 22 10% { 23 -webkit-transform: translate(-2px, -3px) rotate(-2deg); 24 } 25 20% { 26 -webkit-transform: translate(-2px, 0px) rotate(1deg); 27 } 28 30% { 29 -webkit-transform: translate(1px, 5px) rotate(0deg); 30 } 31 40% { 32 -webkit-transform: translate(3px, -1px) rotate(3deg); 33 } 34 50% { 35 -webkit-transform: translate(-1px, 3px) rotate(-1deg); 36 } 37 60% { 38 -webkit-transform: translate(0px, 1px) rotate(0deg); 39 } 40 70% { 41 -webkit-transform: translate(2px, 1px) rotate(-2deg); 42 } 43 80% { 44 -webkit-transform: translate(-1px, -3px) rotate(1deg); 45 } 46 90% { 47 -webkit-transform: translate(3px, 2px) rotate(0deg); 48 } 49 100% { 50 -webkit-transform: translate(1px, -2px) rotate(-1deg); 51 } 52 } 53 </style> 54</head> 55<body> 56<div class="content"> 57 <h2 class="hurueru">このテキストを震えさせたい</h2> 58</div> 59<script src="//code.jquery.com/jquery-3.1.1.min.js"></script> 60<script> 61</script> 62</body> 63</html>
投稿2016/12/07 15:03
退会済みユーザー
総合スコア0
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/07 15:14