2013-08-02 4 views
6

ウィンドウのサイズを変更すると、フローティングdivは次の行に期待通りに折り返されます。しかし、私は本当にこのレイアウトの変更がアニメーション化されることを願っています。CSS3フローティングdivのアニメーションレイアウトの変更

編集:これ以外にも、JQueryに依存しないソリューションを見つけることができればうれしいです。私が必要なら私は自分のjsを書いても構いません。理想的には、私はAngularJSディレクティブにこれを実装したいと思っています。なぜなら、jQueryの依存関係を望まない理由です。ここで

は、私のコードの短縮版である:http://jsfiddle.net/cDS7Q/3/

HTML

<div id="content"> 

    <div>&nbsp;</div> 
    <div>&nbsp;</div> 
    <div>&nbsp;</div> 
    <div>&nbsp;</div> 
    <div>&nbsp;</div> 

</div> 

そして、ここでは私のCSS

body {background-color: #333;} 

#content div { 
    position: relative; 
    float: left; 
    background-color: #eee; 
    margin-left: 10px; 
    margin-bottom: 10px; 
    width: 100px; 
    height: 100px; 

    -webkit-transition: all .2s ease; 
    -moz-transition: all .2s ease; 
    -ms-transition: all .2s ease; 
    -o-transition: all .2s ease; 
    transition: all .2s ease; 
} 

#content { 
    margin-top: 50px; 
    padding-top: $gutter; 
    padding-bottom: 50px; 
    overflow: hidden; 
    width: 100%; 
} 

である私が達成しようとしている効果はこれにsimilairですサイト:http://saffron-consultants.com/journal/

ウィンドウのサイズをブロックが新しい位置にアニメートするのを見てください。

+1

あなたは[同位体](http://isotope.metafizzy.co/) –

+0

ありがとうのようなJSプラグインを探す必要があります。私はそれがJSなしで可能であることを望んでいた。しかし、私は制限があると思います – Andre

+0

2番目の考えでは、私はこのプロジェクトでangularjsを使用し、JQueryに依存しないものを好むでしょう。とにかくその提案をありがとう。多分同位体源が私を良い方向に導くでしょう。 – Andre

答えて

0

あなたはこれのためにクイックサンドを試すことができます。 http://razorjack.net/quicksand/

+0

私は元の投稿にサイドノートを追加しました.JQueryに依存しないソリューションが好きです。しかしクイックサンドを指摘してくれてありがとう – Andre

0

cssでは可能ですが、メディアクエリでパラメータを変更した場合にのみ可能です。例えば

アニメーションを取得するよりも、あなたは、メディアクエリを持つ要素の幅、またはパディングとマージンを変更した場合

。 また、Divsを絶対または相対に配置し、メディアクエリ内の位置を変更すると、それは機能します。

しかし、単純なフローティング/ラッピングではありません。そのためにはJavaScript/jQueryが必要です。例えば

あなたのフィドルにこれを追加します。

body { 
    background-color: #333; 
} 

#content div { 
    position: relative; 
    float: left; 
    background-color: #eee; 
    margin-left: 20px; 
    margin-bottom: 20px; 
    width: 200px; 
    height: 200px; 

    -webkit-transition: all .7s ease; 
    -moz-transition: all .2s ease; 
    -ms-transition: all .7s ease; 
    -o-transition: all .7s ease; 
    transition: all .7s ease; 
} 

#content { 
    margin-top: 50px; 
    padding-top: $gutter; 
    padding-bottom: 50px; 
    overflow: hidden; 
    width: 100%; 
} 

@media screen and (max-width: 480px) { 
#content div { 
    margin-left: 10px; 
    margin-bottom: 10px; 
    width: 100%; 
    height: 100px; 
    } 

} 
関連する問題