2013-01-25 120 views
0

我有一個問題,我很難解決的CSS/HTML。比方說,我們有一個鏈接和H2裏面,使得它看起來像下面對齊底部的文本

Images with lines of one line and two lines

的代碼如下:

<a href="newLink"><h2>This can be one line or two lines or three..</h2></a> 

我需要的線對齊底部如下...另請注意,文本也位於中心以及底部。這個怎麼做?

        Andis AGC Clipper Single 
Andis AGC 2 Speed Clipper      Speed 

回答

1

HTML

<div> 
<h2>one line</h2> 
    <h2 align=center>This can be one line or two lines or three..</h2> 
</div> 

CSS

div{background:grey; width:100%} 
h2{ 
    font-size:20px; 
    color:white; width:49%; 
    display:inline-block 
} 

編輯的Sowmya演示的中心對齊。

+0

我解決了它使用vertical-align:bottom; display:table-cell我還沒有使用所有瀏覽器對它進行測試。 –

+0

現在你應該接受任何答案。以標記該問題已解決。 – Arpit

2

HTML

<div> 
<h2>one line</h2> 
    <h2>This can be one line or two lines or three..</h2> 
</div> 

CSS

div{background:grey; width:100%} 
h2{ 
    font-size:20px; 
    color:white; width:49%; 
    background:red; 
    display:inline-block; 
    text-align:center 
} 

DEMO