javascriptは使わずにCSSとHTMLだけで装飾できるボタンのホバーエフェクトをご紹介します。
コピペですぐ実装できるので、このページをブックマークしておくと便利です。
薄くなるボタン
ボタン01
HTML
<div class="btn01">ボタン01</div>
CSS
.btn01 { display: inline-block; padding: 0.6em 2em; margin: 0 0 1em; background-color: #03c6b9; color: #fff; cursor: pointer; border-radius: 24px; transition: 0.3s ease-in-out; -webkit-transition: 0.3s ease-in-out; } .btn01:hover { opacity: 0.6; }
色が変化するボタン
ボタン02
HTML
<div class="btn02">ボタン02</div>
CSS
.btn02 { display: inline-block; padding: 0.6em 2em; margin: 0 0 1em; background: #fff; border: 0.1875em solid #03c6b9; color: #03c6b9; cursor: pointer; border-radius: 24px; transition: 0.3s ease-in-out; -webkit-transition: 0.3s ease-in-out; } .btn02:hover { background: #03c6b9; color: #fff; }
押した感じのボタン
ボタン03
HTML
<div class="btn03">ボタン03</div>
CSS
.btn03 { border-bottom: 7px solid #006c65; background-color: #03c6b9; color: #fff; display: inline-block; padding: 0.6em 2em; margin: 0; cursor: pointer; border-radius: 24px; transition: 0.3s ease-in-out; -webkit-transition: 0.3s ease-in-out; } .btn03:hover { border-bottom: 0px solid #006c65; margin-top: 7px; }
フワッと浮き上がるボタン
ボタン04
HTML
<div class="btn04">ボタン04</div>
CSS
.btn04 { box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.25); background-color: #03c6b9; color: #fff; display: inline-block; padding: 0.6em 2em; margin: 0 0 1em; cursor: pointer; border-radius: 24px; transition: 0.3s ease-in-out; -webkit-transition: 0.3s ease-in-out; } .btn04:hover { box-shadow: 0 9px 8px -4px rgba(0, 0, 0, 0.25); transform: translateY(-7px); -webkit-transform: translateY(-7px); }
背景に指定した画像が縮小するボタン
ボタン05
HTML
<div class="btn05"> <span><p>ボタン05</p></span> </div>
CSS
.btn05 { position: relative; width: 60%; height: 300px; overflow: hidden; border-radius: 24px; box-shadow: 0 33px 31px -28px rgba(0,0,0,.3); font-size: 40px; font-weight: 800; text-align: center; color: #fff; cursor: pointer; } .btn05 span { width: 100%; height: 100%; display: block; background: url(https://hajimete.org/wp-content/uploads/2019/12/top.jpg); background-position: center; background-size: cover; transition: .3s ease-in-out; -webkit-transition: .3s ease-in-out; transform: scale(1.1); -webkit-transform: scale(1.1); } .btn05 span:hover { transform: scale(1); -webkit-transform: scale(1); } .btn05 span p { position: absolute; top: 50%; left: 0; transform: translateY(-50%); -webkit-transform: translateY(-50%); width: 100%; margin: 0; }
背景に指定した画像が拡大するボタン
ボタン06
HTML
<div class="btn06"> <span><p>ボタン06</p></span> </div>
CSS
.btn06 { position: relative; width: 60%; height: 300px; overflow: hidden; border-radius: 24px; box-shadow: 0 33px 31px -28px rgba(0,0,0,.3); font-size: 40px; font-weight: 800; text-align: center; color: #fff; cursor: pointer; } .btn06 span { width: 100%; height: 100%; display: block; background: url(https://hajimete.org/wp-content/uploads/2019/12/top.jpg); background-position: center; background-size: cover; transition: .3s ease-in-out; -webkit-transition: .3s ease-in-out; transform: scale(1); -webkit-transform: scale(1); } .btn06 span:hover { transform: scale(1.1); -webkit-transform: scale(1.1); } .btn06 span p { position: absolute; top: 50%; left: 0; transform: translateY(-50%); -webkit-transform: translateY(-50%); width: 100%; margin: 0; }
怖いボタン
ボタン07
HTML
<div class="btn07"> <span><p>ボタン07</p></span> </div>
CSS
.btn07 { position: relative; width: 60%; height: 300px; overflow: hidden; border-radius: 24px; background: #03c6b9; box-shadow: 0 33px 31px -28px rgba(0,0,0,.3); font-size: 40px; font-weight: 800; text-align: center; color: #000; cursor: pointer; } .btn07 span { width: 100%; height: 100%; display: block; background: url(https://hajimete.org/wp-content/uploads/2019/06/te.png); background-position: center; background-size: auto 100%; background-repeat: no-repeat; transition: .3s ease-in-out; -webkit-transition: .3s ease-in-out; transform: translateY(100%); -webkit-transform: translateY(100%); } .btn07:hover span { transform: translateY(8px); -webkit-transform: translateY(8px); } .btn07 span p { position: absolute; top: 50%; left: 0; transform: translateY(-50%); -webkit-transform: translateY(-50%); width: 100%; margin: 0; }
コメント