简体   繁体   English

Bootstrap 3水平对齐文本和div中间的跨度

[英]Bootstrap 3 horizontal aligning text and span in middle of div

在此处输入图片说明

I am trying to align the Back To Top and the up carat in the middle of the div container but I can't seem to get it to work. 我正在尝试在div container的中间对齐Back To Top和上克拉,但是我似乎无法使其正常工作。

I am using Bootstrap 3 . 我正在使用Bootstrap 3 How do I get this to align properly in the middle? 我该如何使其在中间正确对齐?

HTML 的HTML

<div class="container-fluid" id="footer">
    <a href="#" class="center-block">
        <p class="text-center" id="back-to-top">Back To Top</p><span class="glyphicon glyphicon-chevron-up"></span>
    </a>
    <p class="text-center" id="copyright">© 2014 LFDate. All rights reserved.</p>
</div>

CSS 的CSS

#back-to-top {
display: inline;
margin-right: 10px;
}

You seem to be wrapping your elements in a non-conventional way (ie a <p> inside an <a> ) 您似乎在以非常规方式包装元素(即<a><p>

I propose a different approach: 我提出了另一种方法:

<div class="container-fluid" id="footer">
    <a href="#" class="center-block">
        <span class="glyphicon glyphicon-chevron-up"></span> Back To Top
    </a>
    <p class="text-center" id="copyright">
      © 2014 LFDate. All rights reserved.
  </p>
</div>

CSS 的CSS

#footer{
  display: table;
}
#copyright {  
  display:table-cell;
  padding: 10px;
}

See Demo 观看演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM