想要在div元素内将href元素居中

时间:2019-07-17 13:34:15

标签: html css

我正在尝试将div中的元素居中,以使其水平居中。这是我的代码段!已经对align attr感到厌倦,但是没有用!

    div.sticky {
      position: -webkit-sticky;
      z-index: 999;
      width: 100%;
      position: fixed;
      bottom: 0px;
      height: 75px;
      margin:0 auto;
      text-align: center;
    }
<div  class="icon-bar sticky ">
      <div class="navbar" >
        <a href="#" class="fa fa " data-toggle="modal" data-target="#emailToSeller"><i class="fa fa-envelope"><span class="tip-content"></i> <br />  {LANG_REPLY_MAIL}</a>
        <a href="{ITEM_AUTHORLINK}"><i class="fa fa-user"<span class="tip-content"> <br />{ITEM_AUTHORNAME}</i></a>
        <a href="tel:{ITEM_PHONE}" class="fa fa-phone"><span class="tip-content"> <br /> {LANG_Call_NOW}</span></a></li>
      </div>
       <!--  End customiztion by ali baba !  -->
    </div>
    

1 个答案:

答案 0 :(得分:1)

要获得预期结果,请对锚标记使用内联块

.navbar a {
  display:inline-block
}

工作代码示例,以供参考

<html>
<head>
<style>
div.sticky {    
  position: -webkit-sticky;
  z-index: 999;
  width: 100%;
  position: fixed;
  bottom: 0px;
  height: 75px;
  margin:0 auto;
  text-align: center; 
  border: 1px solid black;
}
.navbar a{
display:inline-block
}
</style>
</head>
<body>

<div  class="icon-bar sticky ">  
  <div class="navbar" >
    <a href="#" class="fa fa " data-toggle="modal" data-target="#emailToSeller"><i class="fa fa-envelope"><span class="tip-content"></i> <br />  {LANG_REPLY_MAIL}</a>
    <a href="{ITEM_AUTHORLINK}"><i class="fa fa-user"<span class="tip-content"> <br />{ITEM_AUTHORNAME}</i></a>
    <a href="tel:{ITEM_PHONE}" class="fa fa-phone"><span class="tip-content"> <br /> {LANG_Call_NOW}</span></a></li>

  </div>
<!--  End customiztion by ali baba !  -->    
</div>


</body>
</html>