[CSS]アイデアが面白い、ボタンに次々とメッセージを表示するスタイルシート -Story Button
Post on:2013年8月28日
sponsorsr
ボタンをホバーすると、表示メッセージを次々に変更するスタイルシートのデモを紹介します。

こういうボーナス的なトリックって、面白いですよね。
気がついたビジターだけが楽しめたり、ボタンクリックへの背中を一押しするようなメッセージを入れるのもいいかもしれません。
実装は、簡単です。
HTML
a要素で実装したボタンに、メッセージの数分のa要素を量産します。
デモでは、10のメッセージが表示されます。
<div class="button"> <a class="first"> Keep hovering me </a> <a class="slidein"> how are you today? </a> <a class="slidein two"> I'm doing well </a> <a class="slidein three"> thanks for asking </a> <a class="slidein four"> its a good life... </a> <a class="slidein five"> ...being a button </a> <a class="slidein six"> the work is hard </a> <a class="slidein seven"> but enjoyable </a> <a class="slidein eight"> yep, its great </a> <a class="slidein nine"> ... </a> <a class="slidein ten"> save me </a> </div>
CSS
メッセージは個別に表示タイミングを設定できます。
.slidein:nth-child( even ) {
background: lighten( #007eff, 10% ) !important;
}
.slidein:nth-child( odd ) {
background: #007eff !important;
}
.button {
cursor: pointer;
position: relative;
text-align: center;
margin: 46px 10px 0 0;
display: block;
width: 195px;
height: 50px;
text-decoration: none;
font-size: 0.7em;
font-weight: 600;
overflow: hidden;
margin: auto;
.ten {
font-size: 7px;
line-height: 52px;
}
&:hover {
.slidein {
left: 0%;
}
.two {
left: 0%;
transition-delay: 1.5s;
}
.three {
left: 0%;
transition-delay: 3s;
}
.four {
left: 0%;
transition-delay: 4.5s;
}
.five {
left: 0%;
transition-delay: 6s;
}
.six {
left: 0%;
transition-delay: 7.5s;
}
.seven {
left: 0%;
transition-delay: 9s;
}
.eight {
left: 0%;
transition-delay: 10.5s;
}
.nine {
left: 0%;
transition-delay: 13s;
}
.ten {
left: 0%;
transition-delay: 16s;
}
}
.slidein {
background: lighten( #007eff, 10% );
left: -100%;
z-index: 2;
}
a {
text-transform: uppercase;
transition: left 300ms;
letter-spacing: 1px;
background: #007eff;
position: absolute;
font-weight: bold;
z-index: 1;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: #ffffff;
line-height: 50px;
}
}
.text {
width: 100%;
text-align: center;
text-transform: uppercase;
font-size: 11px;
font-weight: bold;
color: #a0a0a0;
display: block;
margin-top: 20px;
letter-spacing: 1px;
a {
text-decoration: none;
color: #007eff;
}
}
sponsors











