2015-11-15 106 views
1

我正在尝试定位垂直页脚。我有文字和标志。徽标右对齐。它的高度为38,页脚高度为80px。但我无法将文字和徽标垂直对齐。垂直对齐中间页脚

#footer { height: 80px; } 
 
#footer .text{margin: 0 auto; width: 1024px; padding-top: 35px;vertical-align:middle;} 
 
#footer .text #logo-footer {background:url("image.png") ; float:right; margin-right:0;width:172px;height:38px;}
<div id="footer"> 
 
<div class="text"> 
 
    some text here 
 
    
 
    <div id="logo-footer"></div> 
 
</div> 
 

 
</div>

+0

请检查链接http://stackoverflow.com/questions/16629561/css-vertical-align-middle-not-working –

回答

1

您可以使用此display:table-cellline-height:38px;

#footer { height: 80px; display:table;background:red;} 
#footer .text{display:table-cell;margin: 0 auto; width: 1024px;height:100%; vertical-align:middle;line-height:38px;} 
#footer .text #logo-footer {background:url("image.png") ; float:right; margin-right:0;width:172px;height:38px;} 

我在这里做一个小提琴:

https://jsfiddle.net/d3m7yxrg/

+0

谢谢,我试了一下,它的位置很好!但是我添加了t #footer {width:100%;}以及如何将.text和.logo-footer放在中间并且其宽度为1024px; –