2011-04-12 123 views
1

想象一下,你有這樣的:如何將兩個左右對齊文本的底部與父容器的底部對齊?

<div class="parent_with_height200px"> 
    <div class="left">This is the left floated text, size 12px</div> 
    <div class="right">This is the right floated text, size 40px</div> 
</div> 

我怎樣才能讓在具有基線父DIV的相互對齊底部的兩個文本「立」?

完全可以更改css/html,這是我想要的結果。

+0

您可以使用定位('底部:0'),但是這取決於你的佈局。 – feeela 2011-04-12 14:53:32

+0

對不起,需要使用流佈局。 – tobefound 2011-04-13 06:00:17

回答

1

由於feeela說,使用位置是你將如何完成這一點。

.parent_with_height200px { 
    height: 200px; 
    position: relative; 
    background-color: #DDDDDD; 
    } 

.left { 
    width: 50%; 
    position: absolute; 
    bottom: 0px; 
    left: 0px; 
    background-color: #999999; 
    } 

.right { 
    width: 50%; 
    position: absolute; 
    bottom: 0px; 
    right: 0px; 
    background: #444444; 
    } 

在這裏看到的輸出:Example

+0

嗯,它很接近,如果真正的流動佈局不能實現,我可以用像素定位。我試圖玩豎直對齊,但無濟於事。你的解決方案也沒有對齊字體的基線,它將文本容器的底部對齊,這是不一樣的。看到這裏:http://jsfiddle.net/GxYx8/13 – tobefound 2011-04-13 06:12:48

+0

如果我理解你正確的,這應該是你在找什麼:[http://jsfiddle.net/GxYx8/23/](http: jsfiddle.net/GxYx8/23/) – 2011-04-13 17:42:25

0

這是你在找什麼?

.left { 
    float:left; 
    width:50%; 
} 
.right { 
    float:left; 
    width:50%; 
} 
+0

你如何解決這個問題將對齊父容器底部的兩個浮點數的內容? – tobefound 2011-04-13 06:05:43