[asp.net-mvc]集中在导航栏上的按钮

标签: html5 Asp.net-MVC
发布时间: 2016/10/9 2:53:16
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我的导航栏上有下列按钮︰

<ul class="nav navbar-nav navbar-right" >

    <div class="btn-group ex" data-toggle="buttons" style="vertical-align:middle">
        <label class="btn btn-primary btn-sm">
            <input type="radio" name="options" id="blocos" value="blocos"> <span class="glyphicon glyphicon-th"></span>
        </label>
        <label class="btn btn-primary btn-sm">
            <input type="radio" name="options" id="lista" value="lista"> <span class="glyphicon glyphicon-align-justify"></span>
        </label>
    </div>
    <a class="btn btn-success btn-sm" id="infopopover" rel="popover" data-style="primary"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></a>
    <input type="hidden" id="modoexibicao" />
    <input type="hidden" id="contratocod" />

    @Html.Partial("_LoginPartial")

</ul>

他们是如下所示︰

enter image description here

我想让他们待在导航栏的中心对齐。怎么办?

解决方法 1:

用下面的 css 代码的工作︰

.navbar-nav {
      height:50px; 
      display:flex; 
      align-items:center;
}

垂直对齐︰ 中间在第二个 div 样式︰

<ul class="nav navbar-nav navbar-right">

    <div class="btn-group ex" data-toggle="buttons" style="vertical-align:middle">
        <label class="btn btn-primary btn-sm">
            <input type="radio" name="options" id="blocos" value="blocos"> <span class="glyphicon glyphicon-th"></span>
        </label>
        <label class="btn btn-primary btn-sm">
            <input type="radio" name="options" id="lista" value="lista"> <span class="glyphicon glyphicon-align-justify"></span>
        </label>
    </div>
    <a class="btn btn-success btn-sm" id="infopopover" rel="popover" data-style="primary"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></a>
    <input type="hidden" id="modoexibicao" />
    <input type="hidden" id="contratocod" />

    @Html.Partial("_LoginPartial")

</ul>
赞助商