首页 新闻 会员 周边

当div设置 position: fixed;之后,如何将嵌套的div垂直居中

0
悬赏园豆:10 [已解决问题] 解决于 2015-12-22 09:24

我想让嵌套其中的两个DIV在一行中居中

<body>

<div id="top_nav">
    <div id="logo">
        <img src="images/logo.png">
    </div>
    <div id="nav">
        <a href="#">关于我们</a>&nbsp;&nbsp;/&nbsp;&nbsp;
        <a href="#">技术能力</a>&nbsp;&nbsp;/&nbsp;&nbsp;
        <a href="#">核心产品</a>&nbsp;&nbsp;/&nbsp;&nbsp;
        <a href="#">销售业绩</a>&nbsp;&nbsp;/&nbsp;&nbsp;
        <a href="#">网上订单</a>&nbsp;&nbsp;/&nbsp;&nbsp;
        <a href="#">联系我们</a>
    </div>
</div>

<div class="content">


</div>
</body>

 

body, div, a, img {
    font-family: "Arial";
    margin: 0;
    padding: 0;
}

#top_nav {
    background-color: #00B4CC;
    width: 100%;
    height: 85px;
    white-space: nowrap;
    position: fixed;
}

#logo {
    display: inline;
}

#nav {
    color: white;
    font-size: 18px;
    line-height: 130px;
    display: inline;
    white-space: nowrap;
    border: 1px solid red;
}

#nav a {
    color: white;
    text-decoration: none;
}

.content {
    border: 1px solid red;
    height: 1000px;
}
horse_leo的主页 horse_leo | 初学一级 | 园豆:17
提问于:2015-12-22 09:01
< >
分享
最佳答案
0
text-align: center;
收获园豆:10
helloZou | 菜鸟二级 |园豆:212 | 2015-12-22 09:21
其他回答(2)
0
  1.  margin: auto;  
  2.   position: absolute;  
  3.   top: 0; left: 0; bottom: 0; right: 0;
搁忆 | 园豆:612 (小虾三级) | 2015-12-22 09:28
0

在这个容器上设置text-align:center,内部的两个div就能居中了。

幻天芒 | 园豆:37175 (高人七级) | 2015-12-22 09:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册