CSSでunderlineをカスタム
A List Apart「CSS Design: Custom Underlines」という記事で紹介されていたTips。記事自体は随分前に書かれたものだが、使えそう感が漂っているので試してみる。
上記サイトで紹介されていたのはこんなソース
CSSソース
a {
text-decoration: none; /* まずデフォルトのラインを消す */
background: url(underline.gif) repeat-x 100% 100%; /* underline用画像を背景として指定し、リピートとポジションを設定 */
padding-bottom: 4px; /* テキストとライン間を調節 */
white-space: nowrap; /* リンクテキストが途中で折り返さないように指定 */
}
※hover時にだけラインを出現させる場合
a {
text-decoration: none;
padding-bottom: 4px;
white-space: nowrap;
}
a:hover {
background: url(underline.gif) repeat-x 100% 100%;
}
至ってシンプルで使いやすい。
即実験
>>RedLine Magazine::underlineをカスタマイズのサンプル
aタグにclassでも指定してライン画像を使い分けてもいろいろ使えそうだし、A List Apartで紹介されてたサンプルみたいにhover時の差替え画像にアニメgifを使ってもユーザーにとって分かりやすそう。ただ、やっぱりユーザーはリンク=普通のunderlineに慣れてるからその辺りには十分考慮したデザインにはすべきなんじゃないかと思う。
で、これ、リンクだけじゃなくてstrongとかで強調したい部分に適応させても面白いなーと。strongに色やボーダーをつけるってのもアリだと思うけど、ちょこっと画像で強調したい時に。
<< CSSで敢えてイメージマップ | floatの親ボックスをoverflowで伸ばす >>
トラックバック
このエントリーのトラックバックURL:
http://redline.hippy.jp/cgi/mt/mt-tb.cgi/90

コメント (1)
I have been surfing online more than three hours today, yet I never found any interesting article like yours. Its pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.
投稿者: Ike Taylor Jersey | 2012年01月10日 02:27