Bootstrap导航栏 - 垂直对齐按钮

时间:2016-10-20 21:10:55

标签: html twitter-bootstrap css3 vertical-alignment

我试图在导航中对齐按钮,但我无法弄清楚如何操作。我放置了一个高度为50px的徽标,并垂直对齐其他导航项目,行高属性为50像素。现在它看起来像这样:

enter image description here

当我向按钮添加行高时,边框会拉出。

这是我的HTML:

<nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <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 alt="Dolm IT" src="img/logo.svg" height="50px">
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">


                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">services</a></li>
                    <li><a href="#">showcase</a></li>
                    <li><a href="#">our team</a></li>
                    <button type="button" class="btn btn-default navbar-btn">get in touch</button>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>

这是我的CSS:

  /*nav*/

    .navbar {
        background-color: transparent;
        border: 0;
    }

    .navbar-default .navbar-nav > li > a {
        color: #01787e;
        font-family: 'Akrobat-ExtraBold';
        font-size: 1rem;
        text-transform: uppercase;
        letter-spacing: 2px;
        margin-right: 50px;
    }

    .navbar-nav li a {
        line-height: 50px;
    }


    /*buttons*/

    .btn-default {
        color: #01787e;
        font-family: 'Akrobat-ExtraBold';
        font-size: 1rem;
        text-transform: uppercase;
        letter-spacing: 2px;
    }

    .btn {
        border: 2px solid #01787e;
        border-radius: 5px;
        padding: 7px 30px;
    }
    }

You can see the issue here.感谢您的帮助。

3 个答案:

答案 0 :(得分:1)

button.navbar-btn课程margin-top 25px提供button.navbar-btn{ margin-top:25px } ,你很高兴。

[XmlArrayItem(ElementName = "CONFIG", Type = typeof(MyConfigSchema))]
public MyConfigSchema[] Schemas { get; set; }

检查小提琴:https://jsfiddle.net/4ku2jhm4/1/

答案 1 :(得分:0)

试试这个。我没有测试它,但它会是这样的。

.nuevo{
    width:auto;
    text-align:center;
    line-height:40px;
    padding:5px;
    background:green;
    display:block;
}

     <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">services</a></li>
                        <li><a href="#">showcase</a></li>
                        <li><a href="#">our team</a></li>
                        <li><a class="nuevo">get in touch</a></li>
                    </ul>

答案 2 :(得分:0)

顶级属性可能是您需要的解决方案。

select a.*, b.name1, c.name1, b2join.url, c2join.url
FROM a
LEFT JOIN b
    on a.aID = b.aID
LEFT JOIN c
    on a.aID = c.aID
LEFT JOIN 
        (SELECT b.aID, b.bID, b2.url
            FROM b
        INNER JOIN b2
            on b.bID = b2.bID) as b2join
    on b2join.aID = a.aID
LEFT JOIN 
        (SELECT c.aID, c.cID, c2.url
            FROM c
        INNER JOIN c2
            on c.cID = c2.cID) as c2join
    on c2join.aID = a.aID
.top {
  top: 50px;
}
.lineheight {
  line-height: 50px;
}
ul {
    list-style-type: none;
    margin: 0;
    overflow: hidden;
    border: 1px solid;
}

li {
    float: left;
    padding: 0px 5px;
}