2013-01-25 121 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