Answer the question
In order to leave comments, you need to log in
How to align links in the middle (relative to the vertical) in Bootstrap3 Navbar and wean the icon from climbing out of the border?
In my navbar, when I add a brand icon, the latter goes outside the navbar. In this case, the links are aligned on top of the navbar, but I need them to be in the middle (relative to the vertical). How to achieve this?
I post my code below:
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ЯРГА</title>
<!-- Bootstrap CSS -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="weidmanns.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Название компании и кнопка, которая отображается для мобильных устройств группируются для лучшего отображения при свертывание -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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>
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
<img style="max-width:150px; margin-top: -7px;"
src="D:\Sieggikods\JaRGA\image\logo_777.jpg">
</a>
</div>
<!-- Группируем ссылки, формы, выпадающее меню и прочие элементы -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-left"><!--Тут линки, которые должны быть слева-->
<li class="active"><a href="#">Главная</a></li>
<li><a href="#">Каталог</a></li>
<li><a href="#">Производство</a></li>
<li><a href="#">Новости</a></li>
<li><a href="#">Статьи</a></li>
<li><a href="#">Контакты</a></li>
</ul>
<!--<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Поиск по сайту">
</div>
<button type="submit" class="btn btn-default">Искать</button>
</form>-->
<ul class="nav navbar-nav navbar-right"><!--Тут линки, которые должны быть справа-->
<li><a href="#">Вход</a></li>
<li><a href="#">Регистрация</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
jkhkhkjh kjhkjh kjk
</div>
</div>
</header>
<h1 class="text-center">Hello World</h1>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Bootstrap JavaScript -->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Because the default height for NavBar elements is 50px, line-height = 20px, and your 192x95 image expands the NavBar itself, shifting all of its elements .
Either change the CSS for the elements around it, or make the image smaller.
Open the browser debugger and look at the parameters of the elements, adjusting your own.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question