gpt4 book ai didi

javascript - 在导航栏中居中字形图标

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

我正在尝试将我的字形图标(及其文本)移动到导航栏的中间,并在您缩小窗口时使其保持居中和响应。而且我不希望它在窗口被塞满时挤在一起,而且我不希望下拉菜单偏向一侧或任何东西(因为提供的解决方案之一就是这样做的,这不是很好).

看过很多 stackexchange 解决方案,例如:

How do I center Glyphicons horizontally using Twitter Bootstrap

Center align "span" text inside a div

how do i get glyphicon in the center of the bootstrap navbar?

但他们没有帮助,我试着修改了一下但无济于事。

这是特别是字形图标和按钮所在的部分:

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse" id="iconButton">
<span class="glyphicon glyphicon-menu-hamburger" style="color:white; vertical-align:middle"></a></span><font color="white"> M E N U</font>
</button>

完整代码如下:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Twenty Eight Interiors</title>
<meta name="description" content="Twenty Eight Interiors">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-inverse" id="my-navbar" style="font-family:Webdings;">
<div class="container">
<div class="navbar-header" id="oneDiv">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse" id="iconButton">
<span class="glyphicon glyphicon-menu-hamburger" style="color:white; vertical-align:middle"></a></span><font color="white"> M E N U</font>
</button>


</div><!-- Navbar Header -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav" id="firstOne">
<li><a href="#" id="designProcess" role="button" id="designProcess">Design Process</a></li>
<li><a href="#" id="profile" role="button" id="profile">Profile</a></li>
<li><a href="#" id="contactInfo" role="button" id="contactInfo">Contact Info</a></li>
</ul>
<ul class="list-inline" id="secondOne">
<li><a href="http://www.facebook.com/" class="socialicon"><img src="facebook.png" hspace="30"></a></li>
<li><a href="http://www.twitter.com/" class="socialicon"><img src="twitter.png" hspace="30"></a></li>
<li><a href="http://www.instagram.com/" class="socialicon"><img src="instagram.png" hspace="30"></a></li>
</ul>
</div>
</div><!-- End Container img src="twitter.png"-->
</nav><!-- End navbar -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
</body>
</html>

有谁知道我如何摆脱这个差距?: enter image description here

编辑:CSS

        <style type="text/css">
#my-navbar{
background:rgba(0,0,0,0.9);
margin-bottom:0;
}

ul#firstOne{
background-color:rgba(48, 50, 50, 0.5);
padding: 20px;
}
ul#secondOne{
padding: 5px;
}
</style>

最佳答案

navbar-toggle 类使您的元素向右浮动。您可以通过移除 float 、将元素设置为显示: block 并将左右边距设置为自动来使按钮居中。

.navbar-toggle {
float: none;
display: block;
margin: 8px auto;
}

参见此处:http://jsfiddle.net/keithburgie/amysg7ru/

关于javascript - 在导航栏中居中字形图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808919/

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