2012-05-28 49 views
0

我有一個關於將元素對齊到另一個底部的絕對和相對位置的問題。我已經設置了這個http://jsfiddle.net/sitrobotsit/xLahG/8/來說明這個問題。基本上,底部對齊的元素與它上面的文本重疊。CSS底部對齊導致重疊的文本

HTML

<div class="subevents"> 
     <ul id="events_gallery"> 
     <li class="events_column"> 
      <img src="http://placekitten.com/130/100"> 
      <h3>Some heading</h3>     
      <p>Some vairable length text. Sed ut perspiciatis 
      unde omnis iste natus error sit voluptatem accusantium.</p> 
      <p class="bottom"><a href="#">Overlapping link</a></p> 
     </li> 
    </ul> 
</div>​ 

CSS

#events_gallery li { 
    border: solid 1px #999; 
    list-style-type: none; 
    position: relative; 
    width: 295px; 
} 

#events_gallery li p, #events_gallery li h3 { 
    left: 139px; 
} 

#events_gallery li img { 
    float: left; 
} 

#events_gallery li .bottom { 
    vertical-align: bottom; 
    position: absolute; 
    bottom: 0; 
} 
+0

? http://jsfiddle.net/xLahG/6/ –

+0

是的!不錯的@tpaksu。我改變了id到一個類,所以html將是有效的http://jsfiddle.net/sitrobotsit/xLahG/10/。隨時發佈您的答案,以便我可以接受它作爲答案。發佈了 – LWilson

+0

。謝謝。 –

回答

0

修改ÿ我們的設計是這樣的:

<div class="subevents"> 
     <ul id="events_gallery"> 
     <li class="events_column"> 
      <a href="#"><img src="http://placekitten.com/130/100"></a> 
      <h3>Some heading</h3>     
      <p class="content">Some vairable length text. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium. </p> 
      <p class="bottom"><a href="#">Find out more</a></p> 
     </li> 
    </ul> 
</div>​ 

和CSS:

#events_gallery li { 
    border: solid 1px #999; 
    margin: 0 0 5px 0; 
    list-style-type: none; 
    position: relative; 
    width: 295px; 
} 

#events_gallery li p, #events_gallery li h3 { 
    padding: 0; 
    margin: 0 0 4px 139px; 
} 


#events_gallery li p.content { 
    margin-bottom:24px;    
} 

#events_gallery li img { 
    float: left; 
    margin: 0 5px 5px 0; 
    padding: 2px; 
} 

#events_gallery li .bottom { 
    vertical-align: bottom; 
    position: absolute; 
    bottom: 0; 
} 
​ 
你想是這樣的權利
0

刪除position:absolute

#events_gallery li .bottom { 
vertical-align: bottom; 
position: absolute; 
bottom: 0; 
} 

,看看它here在行動

+0

感謝@DonCallisto,不幸的是,這並沒有達到我最初想要做的事情,即底層對齊.bottom類。我更新了[示例](http://jsfiddle.net/sitrobotsit/xLahG/8) – LWilson