代码之家  ›  专栏  ›  技术社区  ›  Tom

浮动工具栏位于底部,居中,占当前屏幕宽度的80%

  •  1
  • Tom  · 技术社区  · 16 年前

    我正试图在屏幕底部为我目前正在工作的一个网站实现一个类似Facebook的工具栏。

    目前,我有它100%的屏幕宽度,但我想让它看起来几乎完全像Facebook的工具栏,居中,底部在顶部对齐,大约80%的当前屏幕宽度。

    这是我拥有的工具栏的当前CSS,它是屏幕宽度的100%。

    事先谢谢。

    CSS:

    <style type="text/css">
    #toolbar
    {
    background:url('/_assets/img/toolbar.gif') repeat-x;
    height:25px;
    position:fixed;
    bottom:0px;
    width:100%;
    left:0px;
    border-left:1px solid #000000;
    border-right:1px solid #000000;
    z-index:100;
    font-size:0.8em;
    }   
    </style>
    
    3 回复  |  直到 13 年前
        1
  •  4
  •   KooiInc    16 年前

    用途:

    left:10%;
    right:10%;
    
        2
  •  3
  •   Chris Frederick    13 年前
    width: 80%;
    left: 10%;
    right: 10%;
    

    怎么样?

        3
  •  2
  •   mpen    13 年前

    CSS:

    #container {
        width: 100%;
    }
    #toolbar {
        width: 80%;
        height: 40px;
        margin-right: auto;
        margin-left: auto;
    }
    

    Html:

    <div id="container">
      <div id="toolbar"></div>
    </div>