HTML / CSS / jQuery コーディング

【CSS】アニメーションでキラッと光るボタンを作る


オンマウスでキラッと動きをつけるボタンをCSSで作ります。

◆HTML

<button class="myButt one">
<div class="insider"></div>
キラッと光るボタン
</button>

◆CSS

.myButt {
outline: none;
border: none;
padding: 20px;
display: block;
margin: 50px auto;
cursor: pointer;
font-size: 20px;
background-color: transparent;
position: relative;
border: 2px solid #fff;
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
}

.one {
border-color: #fff;
overflow: hidden;
color: #fff;
}
.one .insider {
background-color: #fff;
width: 100%;
height: 20px;
position: absolute;
left: -165px;
transform: rotateZ(45deg);
-webkit-transform: rotateZ(45deg);
-moz-transform: rotateZ(45deg);
-o-transform: rotateZ(45deg);
-ms-transform: rotateZ(45deg);
}
.one:hover {
background-color: #D5AA5C;
border-color: #fff;
color: #fff;
}
.one:hover .insider {
transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
left: 165px;
}

文字の長さによって、「left」の部分を調整します。

サンプルページはこちら

-HTML / CSS / jQuery コーディング
-, ,

© 2025 Web担当屋 ブログ