2017-06-06 55 views
-1

我主要是一個後端人,所以如果這是一個愚蠢的問題,我很抱歉。如果我錯過了我應該提供的任何信息,我很樂意承認。如何正確對齊沿div底部的不同大小的文本?

我有一個小的貨幣符號,並且我想要沿div底部對齊以使它們的底部像素排成一行。目前看起來像這樣。

number

現在,(我認爲)我有一個包含在正確的地方元素的股利。

div

但正如你可以看到文本流出來。

用於在div CSS中如下...

position: absolute; 
left: 375px; 
top: 15px; 
width: 400px; 
height: 70px; 

併爲分別各幣種和數量的元件。

position: absolute; 
left: 0px; 
bottom: 0px; 
color: #e64611; 

position: absolute; 
left: 15px; 
bottom: 0px; 
color: #e64611; 
font-size: 50px; 
+0

我發現我很快就收到-1票和近距離投票。我能否獲得有關如何改進此問題的反饋? –

+0

您可以使用JSBin或類似軟件進行演示。無論如何,檢查我的答案,我做到了。 –

回答

1

避免使用position: absolute

使用position: relative使貨幣價值的中間:

.currency { 
    font-size:12px; 
    font-weight: bold; 
    position: relative; 
    top:-10px; 
} 

.value { 
    font-size:41px; 
    font-weight: bold; 
} 

也許你會檢查some front-end article約CSS定位是有用的。

Here is the demo.