Bootstrap 3 Navbar菜单项对齐(Bootstrap 3 Navbar menu item alignment)

编程入门 行业动态 更新时间:2024-10-20 16:09:14
Bootstrap 3 Navbar菜单项对齐(Bootstrap 3 Navbar menu item alignment)

网站: http : //www.Spotlightdd.co.uk

由于中间有徽标,我的导航栏尺寸有所增加。 该徽标有一个-margin值,可以与底部边框对齐(我知道它只有几个px)。 我想要做的是将文本向下移动而不仅仅增加导航栏的大小,因此它看起来更加集中在导航栏中。 目前,我已经尝试过使用margin / padding.line-height,我能想到的任何东西只会让文本无效。 如果有人可以尝试对它进行分类,那将是非常棒的。

谢谢

(Navbar html)

<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#"> <img alt="CompanyLogo" src="img/spotlightLogo.png" style = "height: 80px" > </a> <button type="button" class="navbar-toggle collapsed" 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> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav nav-center"> <li><a href="index.html"> HOME </a></li> <li><a href="web-design.html"> WEB DESIGN</a></li> <li><a href="graphic-design.html"> GRAPHIC DESIGN </a></li> <li><a href="social-media.html"> SOCIAL MEDIA </a></li> <li class = "logo"><a href = "index.html"> <img src = "img/spotlightLogo.png" class = "headerLogo img-responsive" alt = "spotlight" style = "height: 150px;"></a></li> <li><a href="printing.html"> PRINTING </a></li> <li class="active"><a href="#"> BRANDING </a></li> <li><a href="video-production.html"> VIDEO PRODUCTION </a></li> <li><a href="contact.html"> CONTACT </a></li> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav>

(Navbar CSS)

.navbar-default { border-bottom: 3px solid #CE1344; background-image: none; background-color: white; } .navbar .navbar-nav { text-align: center; display: inline-block; float: none; vertical-align: top; } li > a { margin-top: 0px; } .navbar .navbar-nav { display: inline-block; float: none; vertical-align: top; } .navbar .navbar-collapse { text-align: center; } .headerLogo { margin-bottom: -50px; }

我试图把相关的每一段代码都放进去。 抱歉,因为css文件目前很乱。

Site : http://www.Spotlightdd.co.uk

I have a navbar that has an increased size due to the logo in the middle. The logo has a -margin value to line it up with the bottom border (I know it's out by a few px). What i'm trying to do is move the text down without just increasing the size of the navbar, so it looks more centered in the navbar. Currently, i've tried using margin/padding.line-height, anything i can think of that would only move the text to no avail. If someone could try a hand at sorting it, that would be brilliant.

Thanks

(Navbar html)

<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#"> <img alt="CompanyLogo" src="img/spotlightLogo.png" style = "height: 80px" > </a> <button type="button" class="navbar-toggle collapsed" 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> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav nav-center"> <li><a href="index.html"> HOME </a></li> <li><a href="web-design.html"> WEB DESIGN</a></li> <li><a href="graphic-design.html"> GRAPHIC DESIGN </a></li> <li><a href="social-media.html"> SOCIAL MEDIA </a></li> <li class = "logo"><a href = "index.html"> <img src = "img/spotlightLogo.png" class = "headerLogo img-responsive" alt = "spotlight" style = "height: 150px;"></a></li> <li><a href="printing.html"> PRINTING </a></li> <li class="active"><a href="#"> BRANDING </a></li> <li><a href="video-production.html"> VIDEO PRODUCTION </a></li> <li><a href="contact.html"> CONTACT </a></li> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav>

(Navbar CSS)

.navbar-default { border-bottom: 3px solid #CE1344; background-image: none; background-color: white; } .navbar .navbar-nav { text-align: center; display: inline-block; float: none; vertical-align: top; } li > a { margin-top: 0px; } .navbar .navbar-nav { display: inline-block; float: none; vertical-align: top; } .navbar .navbar-collapse { text-align: center; } .headerLogo { margin-bottom: -50px; }

I tried to put in every bit of code relevant. Apologies because the css file is a mess at the moment.

最满意答案

尝试将此添加到您的CSS:

.navbar-nav>li{ padding: 20px 0; } .navbar-nav>li.logo{ padding: 0 };

这应该可以解决问题。

Try adding this to your css:

.navbar-nav>li{ padding: 20px 0; } .navbar-nav>li.logo{ padding: 0 };

This should do the trick.

更多推荐

本文发布于:2023-08-05 05:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:菜单项   Navbar   Bootstrap   alignment   item

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!