2011-11-14 11 views
25

मैं एक पंक्ति में छोटे बक्से को संरेखित करने की कोशिश कर रहा हूं। इन बक्से में प्रत्येक में 2 तत्व होते हैं। कुछ मामलों में, पहला तत्व इतना "बहुत" पाठ है, यह 2 लाइनों में विभाजित होता है। यदि ऐसा होता है, तो इस विशेष पंक्ति में अन्य सभी ब्लॉक नीचे दिखाए जाते हैं। http://jsfiddle.net/PMRQ5/इनलाइन-ब्लॉक के साथ मिसाइलमेंट (अन्य तत्व नीचे धक्का)

आप HTML क्षेत्र का आकार बदलने के हैं, तो आप देख सकते हैं कि मैं क्या मतलब है:

लंबी कहानी संक्षेप में, यहाँ उदाहरण है। क्या कोई मदद कर सकता है?

.songlist .even { 
 
    background: #c2e4fa; 
 
    background: -moz-linear-gradient(top, #d9eefc, #c2e4fa); 
 
    margin-right: 5px; 
 
} 
 
.songlist .odd { 
 
    background: #faf4c2; 
 
    background: -moz-linear-gradient(top, #fcf8d9, #faf4c2); 
 
    margin-right: 5px; 
 
} 
 
.songlist .itemBox { 
 
    font-size: 11px; 
 
    width: 220px; 
 
    min-height: 100px; 
 
    clear: both; 
 
    padding: 5px; 
 
    margin: 5px 10px 5px 10px; 
 
    display: inline-block; 
 
    position: relative; 
 
    border-radius: 4px; 
 
} 
 
.songlist .itemBox .title { 
 
    font-weight: bold; 
 
    font-size: 16px; 
 
} 
 
.songlist .itemBox .artist { 
 
    clear: left; 
 
    font-size: 11px; 
 
} 
 
.songlist .itemBox .titlerating { 
 
    bottom: 10px; 
 
    left: 10px; 
 
    position: absolute; 
 
} 
 
.songlist .itemBox .dance { 
 
    bottom: 5px; 
 
    right: 10px; 
 
    position: absolute; 
 
}
<div class='songlist'> 
 
    <div class='itemBox even'> 
 
    <div class='cover'></div> 
 
    <div class='title'>You and you</div> 
 
    <div class='artist'>101 Strings Orchestra</div> 
 
    <div class='clear'></div> 
 
    </div> 
 
    <div class='itemBox odd'> 
 
    <div class='title'>The Queen's lace hankerchief waltz</div> 
 
    <div class='artist'>101 Strings Orchestra</div> 
 
    <div class='clear'></div> 
 
    </div> 
 
    <div class='itemBox even'> 
 
    <div class='cover'></div> 
 
    <div class='title'>Voices of spring</div> 
 
    <div class='artist'>101 Strings Orchestra</div> 
 
    <div class='clear'></div> 
 
    </div> 
 
    <div class='itemBox odd'> 
 
    <div class='cover'></div> 
 
    <div class='title'>Roses from the south</div> 
 
    <div class='artist'>101 Strings Orchestra</div> 
 
    <div class='clear'></div> 
 
    </div> 
 
</div>

+0

गाह, यह आप मूल्यों का एक अजीब मिश्रण का उपयोग कर रहे इस प्रभाव को प्राप्त करने लगता है। आपका वांछित परिणाम वास्तव में क्या है? इनलाइन-ब्लॉक का उपयोग करते समय "तत्वों की ओर बढ़ना" मानक है। क्या आप चाहते हैं कि जब विंडो का आकार बदल जाए तो उन्हें शीर्ष रेखा से कभी नहीं ले जाना चाहिए? – Kyle

उत्तर

100

http://jsfiddle.net/PMRQ5/1/

vertical-align: top या vertical-align: bottom बॉक्स में जोड़े, आप क्या चाहते हैं पर निर्भर करता है।

+4

बहुत बहुत धन्यवाद - यह समाधान था :) – simon

+0

मेरे लिए काम नहीं करता है और यह मुझे पागल कर रहा है ... http://jsfiddle.net/CPAtE/ – ProblemsOfSumit

+0

आपको लंबवत-संरेखण को '.slide पर सेट करना होगा ': http://jsfiddle.net/CPAtE/1/ – JNDPNT

0

.songlist .even { 
 
    background:#c2e4fa; 
 
    background:-moz-linear-gradient(top,#d9eefc,#c2e4fa); 
 
    margin-right:5px; 
 
} 
 
.songlist .odd { 
 
    background:#faf4c2; 
 
    background:-moz-linear-gradient(top,#fcf8d9,#faf4c2); 
 
    margin-right:5px; 
 
} 
 
.songlist .itemBox { 
 
    font-size:11px; 
 
    width:220px; 
 
    min-height:100px; 
 
    clear:both; 
 
    padding:5px; 
 
    margin:5px 10px 5px 10px; 
 
    display:inline-block; 
 
    position:relative; 
 
    border-radius:4px; 
 
    vertical-align: bottom; 
 
} 
 
.songlist .itemBox .title { 
 
    font-weight:bold; 
 
    font-size:16px; 
 
} 
 
.songlist .itemBox .artist { 
 
    clear:left; 
 
    font-size:11px; 
 
} 
 
.songlist .itemBox .titlerating { 
 
    bottom:10px; 
 
    left:10px; 
 
    position:absolute; 
 
} 
 
.songlist .itemBox .dance { 
 
    bottom:5px; 
 
    right:10px; 
 
    position:absolute; 
 
}
<div class='songlist'> 
 
    <div class='itemBox even'> 
 
     <div class='cover'></div>   
 
     <div class='title'>You and you</div> 
 
     <div class='artist'>101 Strings Orchestra</div>   
 
     <div class='clear'></div> 
 
    </div>      
 
    <div class='itemBox odd'>  
 
     <div class='title'>The Queen's lace hankerchief waltz</div> 
 
     <div class='artist'>101 Strings Orchestra</div>   
 
     <div class='clear'></div> 
 
    </div> 
 
    <div class='itemBox even'> 
 
     <div class='cover'></div>  
 
     <div class='title'>Voices of spring</div> 
 
     <div class='artist'>101 Strings Orchestra</div>  
 
     <div class='clear'></div> 
 
    </div>      
 
    <div class='itemBox odd'> 
 
     <div class='cover'></div>   
 
     <div class='title'>Roses from the south</div> 
 
     <div class='artist'>101 Strings Orchestra</div>  
 
    <div class='clear'></div> 
 
    </div> 
 
</div>

संबंधित मुद्दे