我的导航面板有问题。我希望社交媒体图标位于右上角并且没有悬停。
我尝试了许多解决方案padding
margin
justify-content-center
justify-content-end
flex
我不知道该怎么做才能使其完全响应。我花了将近三个小时来尝试应用不同的解决方案。
非常感谢您的帮助!
.navbar {
background-color: white;
position: top;
margin-bottom: 0;
z-index: 9999;
border: 0;
font-size: 18px;
line-height: 1.42857143;
letter-spacing: 4px;
border-radius: 0;
}
.navbar li a,
.navbar .navbar-brand {
color: #000000 !important;
}
.navbar-nav li a:hover,
.navbar-nav li.active a {
background-color: #000000 !important;
color: #ffffff !important;
}
.navbar-default .navbar-toggle {
border-color: transparent;
color: #fff;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/3/w3.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top font">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#up" class="navbar-brand"><strong>M</strong></a>
</div>
<div class="collapse navbar-collapse navbar-right" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#about">O MNIE</a></li>
<li><a href="#work">JAK PRACUJEMY</a></li>
<li><a href="#portfolio">PROJEKTY</a></li>
<li><a href="#contact">KONTAKT</a></li>
<li><a href="#"><i class="fab fa-sm fa-instagram"></i></a></li>
<li><a href="#"><i class="fab fa-sm fa-facebook"></i></a></li>
</ul>
</div>
</div>
</nav>
答案 0 :(得分:0)
.navbar {
background-color: white;
position: top;
margin-bottom: 0;
z-index: 9999;
border: 0;
font-size: 18px;
line-height: 1.42857143;
letter-spacing: 4px;
border-radius: 0;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
.navbar li a,
.navbar .navbar-brand {
color: #000000 !important;
padding: 15px;
}
.navbar-nav li a:hover,
.navbar-nav li.active a {
background-color: #000000 !important;
color: #ffffff !important;
}
.navbar-default .navbar-toggle {
border-color: transparent;
color: #fff;
}
#brand {
margin-left: 400px;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<nav class="navbar navbar-light navbar-expand-md bg-light justify-content-center">
<a href="/" class="navbar-brand mr-0 font-weight-bold" id="brand">M</a>
<button class="navbar-toggler ml-1" type="button" data-toggle="collapse" data-target="#collapsingNavbar2">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse justify-content-between align-items-center w-100" id="collapsingNavbar2">
<ul class="navbar-nav mx-auto text-center" id="nav-items">
<li class="nav-item">
<a class="nav-link" href="#">O MNIE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">JAK PRACUJEMY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">PROJEKTY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">KONTAKT</a>
</li>
</ul>
<ul class="nav navbar-nav flex-row justify-content-center flex-nowrap">
<li class="nav-item"><a class="nav-link" href=""><i class="fab fa-facebook mr-1"></i></a></li>
<li class="nav-item"><a class="nav-link" href=""><i class="fab fa-twitter"></i></a> </li>
</ul>
</div>
</nav>
如果您确实在此处运行摘要,请在全页视图中进行操作:)