自定义高度Bootstrap的navbar [英] Custom height Bootstrap's navbar

查看:1384
本文介绍了自定义高度Bootstrap的navbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个高度为150px的标题,其中包含一个导航栏。导航栏应在标题中垂直居中。

I want a header with a height of 150px which contains a navbar. The navbar should be vertically centered in the header.

HTML

<header>
    <div class="navbar navbar-static-top">
        <div class="navbar-inner">
            <div class="container" style="background:yellow;">
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-th-list"></span>
                </a>
                <a href="/"><img src="img/logo.png" class="logo" /></a>
                <nav class="nav-collapse collapse pull-right" style="line-height:150px; height:150px;">          
                    <ul class="nav" style="display:inline-block;">
                        <li><a href="">Portfolio</a></li>
                        <li><a href="">Blog</a></li>
                        <li><a href="">Contact</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</header>

CSS

header {
    width: 100%;
    line-height: 150px;
    color:red;
    height: 150px;

    .navbar-inner {
        border:0;
        border-radius: 0;
        background: blue;
        padding:0;
        margin:0;
        height: inherit;
    }
}

导航/菜单/垂直列表现在标题的右上角。如何让它垂直居中? bootstrap.css是不定制的。

The nav/menu/vertical list is now in the top right of the header. How do I get it to center vertically? bootstrap.css is uncustomized.

推荐答案

你的标记有点搞砸了。这里是您需要的样式和正确的HTML

your markup was a bit messed up. Here's the styles you need and proper html

CSS

.navbar-brand,
.navbar-nav li a {
    line-height: 150px;
    height: 150px;
    padding-top: 0;
}

HTML

<nav class="navbar navbar-default">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <a class="navbar-brand" href="#"><img src="img/logo.png" /></a>
    </div>

    <div class="collapse navbar-collapse">
        <ul class="nav navbar-nav">
            <li><a href="">Portfolio</a></li>
            <li><a href="">Blog</a></li>
            <li><a href="">Contact</a></li>
        </ul>
    </div>
</nav>

或查看小提琴:http://jsfiddle.net/TP5V8/1/

这篇关于自定义高度Bootstrap的navbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆