Skip to content

Instantly share code, notes, and snippets.

@masaki925
Last active August 29, 2015 14:23
Show Gist options
  • Save masaki925/52760bf734bb16516dc6 to your computer and use it in GitHub Desktop.
Save masaki925/52760bf734bb16516dc6 to your computer and use it in GitHub Desktop.
CSS のお勉強(クラス セレクタの書き方)
<html>
<head>
<meta charset="utf-8">
<style>
.hoge1 {
color: red;
}
.hoge2.hoge3 {
background: red;
}
.hoge4 .hoge5 {
color: blue;
}
.hoge6 .hoge7 .hoge8 {
text-align: right;
}
</style>
</head>
<body>
<div>
<p class="hoge1">hoge1</p>
<p class="hoge2 hoge3">ドットで繋げると、両方がついている要素にのみ適用される</p>
<div class="hoge4">
<p class="hoge5">スペースを入れると、階層としてクラスを持つ要素にのみ適用される</p>
</div>
<div class="hoge6 hoge7">
<p class="hoge8">これは適用されない。正しくは、.hoge6.hoge7 .hoge8 のように、hoge6 とhoge7 を繋げる</p>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment