gpt4 book ai didi

html - 无法在没有 anchor 的情况下垂直对齐导航栏中的文本

转载 作者:太空宇宙 更新时间:2023-11-04 02:49:55 24 4
gpt4 key购买 nike

如果我使用以下组合:

<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<ul class="nav navbar-nav">
<li><a><span class="glyphicon glyphicon-earphone"></span> 99999999</a></li>
</ul>
</div>
</nav>

我得到了所需的输出,因为电话号码在导航栏中垂直居中。

但是,它只适用于 <a> ,如果我删除它,它就会到达顶部。

我试过了<li class="navbar-btn">但无济于事。

是否有使用 bootstrap css 的解决方法?

最佳答案

您可以使用内置的 navbar-text 类。参见 Docs .

*如果您使用所有 navbar 选项,我会提供两个示例。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<p class="navbar-text"><span class="glyphicon glyphicon-earphone"></span> 99999999</p>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a>

</li>
</ul>
</div>
</nav>
<hr>
<h3>Full Navbar</h3>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- 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="#">Brand</a>

<p class="navbar-text"><span class="glyphicon glyphicon-earphone"></span> 99999999</p>
</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">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a>

</li>
<li><a href="#">Link</a>

</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>

<ul class="dropdown-menu">
<li><a href="#">Action</a>

</li>
<li><a href="#">Another action</a>

</li>
<li><a href="#">Something else here</a>

</li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a>

</li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a>

</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

关于html - 无法在没有 anchor 的情况下垂直对齐导航栏中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33222805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com