10
09/2014
confusing css
~ VS. +
- A ~ B means All B after A
- C + D means D immediately after C.
Example code:
<style> .a ~ .b {background:red;color:#fff;} .c + .d {background:blue;color: #fff;} </style> <p class="a">1111</p> <p class="b">1111</p> <p class="b">1111</p> <p>other p</p> <p class="b">1111</p> <ul> <li class="b">this is li</li> </ul> <p class="b">after list</p> <p class="c">1111</p> <p class="d">1111</p> <p class="d">1111</p> <p>222</p> <p class="d">1111</p>
The resule:
1111
1111
1111
other div
1111
- this is li
after list
2222
2222
2222
:target
click this link anchor see browser location address: #test_target
the Code
<style> :target {background:purple;color:#fff;} </style> <a href="#test_target">click here</a> <div id="test_target">see browser location bar:......#test_target</div>