最終更新:2012-12-05 (水) 15:08:35 (4158d)  

CSS
Top / CSS

バージョン

http://desperadoes.biz/style/index.php

書き方

基本

/*セレクタ{プロパティ:値}*/
h1 {font-size:150%;}
}

id,class,attribtue

hoge.huga //class = fuga
hoge#huga //id = fuga
hoge[foo=bar] //attribute foo = bar


p.note{}//class=noteの<p>

//class=noteの全要素
*.note{}
.note{}
.foo.bar //class="foo bar"の要素

//IDセレクタ
//id=headerの部分
#header {}
#header h2{}//idがheaderのh2

子孫セレクタ

//子孫セレクタ(スペース)
tag1 tag2{}
tag1 * tag2{}
tag1.className tag2{}

tag1   tag2{}//子孫( )
tag1 > tag2{}//直接の子(>)
tag1 + tag2{}//次のノード(+)
tag1 ~ tag2{}//一個前
 

グルーピング

.icon-facebook,  
.icon-twitter,  
.icon-delicious {  
    padding-left:  26px;  
    margin-right:  20px;  
    width:        100px;  
}  
.icon-facebook{background:url(facebook.gif);}  
.icon-twitter{background:url(twitter.gif);}  
.icon-delicious{background:url(delicious.gif);}  

擬似クラス

a:link{}
a:visited{}

a:focus{}
a:hover{}
a:active{}
 

その他

読み易く

参考