マウスオーバー時に文字・背景に変化を!?
初心者向けスタイルシート!!
昨日に続きCSS(スタイルシート)に関する初級編テクニックを書いて置こうと思います。
- マウスオーバー時に文字色が変わる
スタイルシートの書き方
- マウスオーバー時に背景色が変わる
スタイルシートの書き方
- マウスオーバー時に背景色が変わり文字サイズ大きくなる
スタイルシートの書き方
<style>
.button1{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button1:hover{ /*※マウスオーバー時*/
color: blue; /*※文字色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
.button1{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button1:hover{ /*※マウスオーバー時*/
color: blue; /*※文字色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
<a href="#" class="button1"><div class="button1">こんにちは</div></a>
<style>
.button2{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button2:hover{ /*※マウスオーバー時*/
background: yellow; /*※背景色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
.button2{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button2:hover{ /*※マウスオーバー時*/
background: yellow; /*※背景色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
<a href="#" class="button2"><div class="button2">こんにちは</div></a>
<style>
.button3{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button3:hover{ /*※マウスオーバー時*/
width: 170px; /*※幅*/
font-size: 130%; /*※文字サイズ*/
background: yellow; /*※背景色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
.button3{
width: 140px; /*※幅*/
font-size: 110%; /*※文字サイズ*/
color: #ff0000; /*※文字色*/
background: lime; /*※背景色*/
display: inline-block; /*※改行しない横並び*/
font-weight: bold; /*※文字の太さ*/
text-align: center; /*※中央揃え*/
}
.button3:hover{ /*※マウスオーバー時*/
width: 170px; /*※幅*/
font-size: 130%; /*※文字サイズ*/
background: yellow; /*※背景色*/
text-decoration: none; /*※リンク時の下線削除*/
}
</style>
<a href="#" class="button3"><div class="button3">こんにちは</div></a>