CSSコードスニペット - 使えるCSS小技15選

2009/01/29 11:56Update
TAGS: CSS | コードスニペット | サンプル

使えそうなCSSコードスニペット、CSS小技15選。

原文は:CSS Code Snippets : 15 Wicked Tricks | DevSnippets

簡単に紹介します。

1、text-indentでテキストの非表示(その代わりに、画像を表示させる)
コード:
h1 {
text-indent:-9999px;/*Hide Text, keep for SEO*/
margin:0 auto;
width:948px;
background:transparent url("images/header.jpg") no-repeat scroll;
}


2、クロスブラウザーのMinimum-Height(最小縦幅)設定
コード:
#container  { min-height:500px; } * html #container { height:500px; }


もしくは
コード:
#container{
height:auto !important;/*all browsers except ie6 will respect the !important flag*/
min-height:500px;
height:500px;/*Should have the same value as the min height above*/
}



3、新規ウィンドウで開くリンクのハイライト表示
コード:
a[target="_blank"]:before,
a[target="new"]:before {
margin:0 5px 0 0;
padding:1px;
outline:1px solid #333;
color:#333;
background:#ff9;
font:12px "Zapf Dingbats";
content: "\279C";
}


4、PDFやWordへのリンクのハイライト表示
コード:
a[href$="pdf"]:after,
a[href$="doc"]:after {
margin:0 0 0 5px;
font:bold 12px "Lucida Grande";
content: " (PDF)";
}
a[href$=".doc"]:after {content: " (DOC)";}


・・・

6、float属性を簡単にクリアする方法
コード:
<div id="outer">
        <div id="inner"> <h2>A Column</h2> </div>
        <h1>Main Content</h1>
        <p>Lorem ipsum</p>
</div>


コード:
#inner{  
width:26%;  
float:left;  
}  
#outer{  
width:100%;
overflow:auto;
}


・・・

14、CSSで丸角効果
コード:
.container{
    background-color: #fff;
    margin: 10px;
    padding: 10px;
    -moz-border-radius-topleft: 20px;
    -webkit-border-top-left-radius: 20px;
    -moz-border-radius-bottomright: 20px;
    -webkit-border-bottom-right-radius: 20px;
}


・・・

有关作者
Syboos.jp編集長AJavaやオープンソース情報の執筆、Webサイトの開発や運営全般の業務に携わる。

Sponsored Link


Comments

用户名 (required)

Email (will not be published) (required)

URL

Evaluation