私が選択したli
にクラスを追加して適用するCSS3の擬似セレクタを使用し、位置に基づいて明確な山車されるだろうと考えることができます最善の方法。
li.active ~ li:nth-of-type(1n+2) {
float: left
}
li.active ~ li:nth-of-type(1n+2):after {
content: '\0a00' // whitespace
width: 0;
height: 0;
line-height: 0;
clear: left;
}
私はセレクタについて説明します。
/ the ~ (tilde) is an adjacent element selector, imagine the following html
<li></li>
<li></li>
<li class="active"></li>
<li></li>
<li></li>
And css
li.active ~ li {
background-color: green;
}
// the ~ would select all the li elements that come after the the occurence of
// .active element and apply a green background. illustrated below with an *
<li></li>
<li></li>
<li class="active"></li>
<li></li> *
<li></li> *
n番目-の型セレクタは、あなたは、これは非常にエレガントな解決策である、それがかかる場合があります組み合わせるマッチした要素
using previous html
with this css
// the nth-of-type value can also be an equation e.g. 1n + 2
li:nth-of-type(2) {
background-color: green;
}
<li></li>
<li></li> *
<li class="active"></li>
<li></li>
<li></li>
li.active ~ li:nth-of-type(2) {
background-color: green;
}
<li></li>
<li></li>
<li class="active"></li>
<li></li>
<li></li> *
の独立した兄弟を選択することができますいくつかは、あなたが望む結果を得るためにいじるが、あなたは確かにそれを行うには、CSSでのツールを持っています。ここで
はCSS3のセレクタと彼らがやるの完全なリストです。
http://www.w3.org/TR/css3-selectors/#selectors
あなたはマニュアルに記載されているものよりも優れた使用例を見つけるために周りを掘る必要があるかもしれませんが、少なくともあなたは、検索するために何を知っています。
それは明らかにこれをサポートする唯一の近代的なブラウザですが、あなたは
ie9.js
http://code.google.com/p/ie7-js/
か、そのソリューションは、あなたの空想
をつかむしない場合とIEのサポートを修正することができます
前のjQuery石積みの提案を強くお勧めします。
http://masonry.desandro.com/
[Masonry](http://masonry.desandro.com/index.html)を見ることをお勧めします。 – Pointy
は、あなただけの選択 'li'の高さと幅を変更しようとしたことがありますか?それはうまくいくはずです、ちょうどあなたがそれを見たいかどうかに応じて、他のアイテムがどのようにラップアラウンドするかで遊ぶ必要があります。 –
[Isotope](http://isotope.metafizzy.co/)をチェックする価値があります。似て石造り、唯一のクーラー:) –