页脚文本和垂直对齐问题

时间:2013-05-09 20:18:36

标签: html css

我试图让我的页脚文本在我的页脚DIV中垂直对齐,但这不起作用。我试了vertical-align: middle没有成功。有什么问题?非常感谢 JSfiddle:http://jsfiddle.net/Grek/hqdP2/

<div class="menu">
      <div class="inner"> <a href="www.dfdsfdsfs.com/index.html" class="logo">Gregory</a>
    <ul>
          <li > <a href="www.dfdsfdsfs.com">Category 1</a> </li>
          <li > <a href="www.dfdsfdsfs.com">Category 2</a> </li>
          <li > <a href="www.dfdsfdsfs.com">Category 3</a> </li>
          <li > <a href="www.dfdsfdsfs.com">Category 4</a> </li>
          <li > <a href="www.dfdsfdsfs.com">Category 5</a> </li>
          <li class="selected"> <a href="www.dfdsfdsfs.com/">Category 6</a> </li>
          <li > <a href="www.dfdsfdsfs.com">Contact</a> <span class="pipe"></span> </li>
        </ul>
    <div class="social">
          <div class="fb-like" data-href="http://www.123.com" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
        </div>
  </div>
    </div>
<div id="quote">
      <blockquote>
    <p>"Nos soutenons depuis la début"</p>
    <cite>Innovation</cite> </blockquote>
      <blockquote>
    <p>"L'exceptionnelle"</p>
    <cite>Hydro-geologiste</cite> </blockquote>
    </div>

<div class="article content">
      <h1>Biography</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <a class="image-popup-vertical-fit" href="http://farm9.staticflickr.com/8241/8589392310_7b6127e243_b.jpg" title="Caption. Can be aligned it to any side.">
    <img src="http://farm9.staticflickr.com/8241/8589392310_7b6127e243_s.jpg" width="75" height="75">
</a><h2>Sub-title</h2><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
    <p><strong>LOREM IPSUM</strong></p>
          <h3>Tel. +123 456.789 - E-mail: contact@kjhhklh.com</h3>
  </div>


    </div>

<div class="footer">
      <p class="left">contact@mydomain.com | + 12 345.678.910</p>
      <p class="right">contact@mydomain.com | + 12 345.678.910</p>
    </div>
</body>
</html>

CSS:

/* Footer
/* -------------------------------------------- */
.footer {
    position: fixed;
    z-index: 300;
    bottom: 0;
    width: 100%;
    min-width: 768px;
    max-width: 1950px;
    margin: 0 auto;
    background: #2b2b2b;
}
.footer a {
    color: #fff;
    text-transform: uppercase;
    border-bottom-color: #2b2b2b;
}
.footer a:hover {
    border-bottom-color: #ECB825;
}
.footer p.left {
    display: inline-block;
    float: left;
    color: #fff;
    padding-left: 20px;
    vertical-align: middle;
    font-family: 'Futura W01 Heavy', Arial, sans-serif;
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    padding-bottom: 1px;
}
.footer p.right {
    display: inline-block;
    float: right;
    padding-right: 20px;
    color: #fff;
    padding-left: 20px;
    vertical-align: middle;
    font-family: 'Futura W01 Heavy', Arial, sans-serif;
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    padding-bottom: 1px;
}

3 个答案:

答案 0 :(得分:2)

我会对您的CSS进行以下调整:

.footer {
    height: 50px;
    line-height: 50px;
    vertical-align: middle;
}

.footer p.left {
    xxvertical-align: middle;
    xxline-height: 1;
}
.footer p.right {
    xxvertical-align: middle;
    xxline-height: 1;
}

height中的line-height.footer声明为某个固定值。删除p.leftp.right中的这两个属性。

只要您有单行内容,这应该没问题。

小提琴:http://jsfiddle.net/audetwebdesign/hqdP2/4/

答案 1 :(得分:1)

一种可能的解决方案是调整line-height.footer p.left中的.footer p.right值。 line-height: 2.0em之类的内容会根据您现有的示例垂直对齐。或者您应该在height中设置.footer,并使line-height中的.footer p.left.footer p.right等于height中的.footer

答案 2 :(得分:0)

您的.footer p有最低保证金。用顶部和底部边距覆盖它,例如:

.footer p {
    margin: 10px 0;
}