I wrote a media query that remove the hamburger menu automatically on a certain resolution but for some reason, when the menu is collapsed and I try to expand it, the menu is closing automatically, this is the code:
#media (min-width: 768px) {
.navbar-toggler {
display: none;
}
}
#media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,
.navbar-right {
float: none !important;
}
.navbar-toggler {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none !important;
}
.navbar-nav {
float: none !important;
margin-top: 7.5px;
}
.navbar-nav > li {
float: none;
}
.navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in {
display: block !important;
}
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js"></script>
<nav class="navbar navbar-inverse navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="#">
<img src="http://placehold.it/150x50?text=Logo" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
as you can see this happen only when the menu is collapsed and I try to expand it, what I did wrong?
The problem is in the property:
#media (max-width: 1200px) {
/* ... */
.navbar-collapse.collapse {
display: none !important;
}
}
After the animation, Bootstrap adds a collapse class to your menu.
You're overwriting the default behavior hiding the menu for every resolution less than 1200px.
I hope this answer could help you! 😉
#media (min-width: 768px) {
.navbar-toggler {
display: none;
}
}
#media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,
.navbar-right {
float: none !important;
}
.navbar-toggler {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-nav {
float: none !important;
margin-top: 7.5px;
}
.navbar-nav > li {
float: none;
}
.navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in {
display: block !important;
}
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js"></script>
<nav class="navbar navbar-inverse navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="#">
<img src="http://placehold.it/150x50?text=Logo" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
Related
I am struggling with changing the color of my font in my nav bar button eg. Home to white. In my style.css file I first used .navbar-nav li but then the padding did not work, when I changed it to .navbar-nav ul the padding then worked. I then had to use .navbar-nav li a for the next style syntax to work and all seem to work except for the color syntax. Please advise what I am doing wrong for the color syntax not to work.
The color syntax again does not work in my .fa-bars class conditions but the font size in that class does work.
The last problem I seem to have is that the syntax in my .promo-title class does not work. Any help would be much appreciated. Thanks.
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
}
#nav-bar {
position: sticky;
top: 0;
z-index: 10;
/* sticky on the top */
}
.navbar {
background-image: linear-gradient(to right, #a517ba, #5f1782);
padding: 0;
}
.navbar-brand img {
height: 40px;
padding-left: 20px;
}
.navbar-nav ul {
padding: 0 10px;
}
.navbar-nav li a {
color: #fff;
/*Not working letters in nav bar not white*/
font-weight: 600;
float: right;
text-align: left;
}
.fa-bars {
color: #fff;
/*Not working menu bars not white*/
font-size: 30px;
}
.navbar-toggler {
outline: none;
}
/*--------------banner section------------*/
#banner {
background-image: linear-gradient(to right, #a517ba, #5f1782);
color: #fff;
padding-top: 5%;
/*Extended purple banner down*/
}
.promo-title {
font-size: 40px;
font-weight: 600;
margin-top: 100px;
}
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.2.1/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.2.1/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/#fortawesome/fontawesome-free#5.15.4/css/fontawesome.min.css">
</head>
<body>
<section id="nav-bar">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="#"> <img src="https://via.placeholder.com/50"> </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
<i class="fa fa-bars" aria-hidden="true"></i> <!--adds menu bars when shrinking screen or in mobile view-->
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<!--ml-auto moves navbar to the right side-->
<li class="nav-item">
<a class="nav-link" href="#">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">SERVICES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ABOUT US</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
</section>
<!--Banner section-->
<section id="banner">
<div class="container">
<div class="row">
<div class="col-md-6">
<p class="promo-title">BEST CUSTOM DATABASE COMPANY</p>
<p>Add sentence here not sure what to say just yet but has to be good</p>
</div>
</div>
</div>
</section>
</body>
Your selector specificity isn't high enough, so the Bootstrap styles take precedence. A quick look at your browser's document inspector reveals this. Use a more specific selector.
The same is true for the button (but you should remove the default Bootstrap icon).
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
}
#nav-bar {
position: sticky;
top: 0;
z-index: 10;
/* sticky on the top */
}
.navbar {
background-image: linear-gradient(to right, #a517ba, #5f1782);
padding: 0;
}
.navbar-brand img {
height: 40px;
padding-left: 20px;
}
.navbar-nav ul {
padding: 0 10px;
}
.navbar.navbar-light .navbar-nav li a {
color: #fff;
font-weight: 600;
float: right;
text-align: left;
}
body .navbar-light .navbar-toggler {
color: #fff;
border-color: #fff;
font-size: 30px;
}
.navbar-toggler {
outline: none;
}
/*--------------banner section------------*/
#banner {
background-image: linear-gradient(to right, #a517ba, #5f1782);
color: #fff;
padding-top: 5%;
/*Extended purple banner down*/
}
.promo-title {
font-size: 40px;
font-weight: 600;
margin-top: 100px;
}
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.2.1/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.2.1/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/#fortawesome/fontawesome-free#5.15.4/css/fontawesome.min.css">
</head>
<body>
<section id="nav-bar">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="#"> <img src="https://via.placeholder.com/50"> </a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<i class="fa fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<!--ml-auto moves navbar to the right side-->
<li class="nav-item">
<a class="nav-link" href="#">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">SERVICES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ABOUT US</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
</section>
<!--Banner section-->
<section id="banner">
<div class="container">
<div class="row">
<div class="col-md-6">
<p class="promo-title">BEST CUSTOM DATABASE COMPANY</p>
<p>Add sentence here not sure what to say just yet but has to be good</p>
</div>
</div>
</div>
</section>
</body>
You can use
a.nav-link{
color:#fff!important;
}
I'm coding a navbar in Bootstrap. When an anchor link is active or selected, there is a border around it that is black and the resulting text is white. The goal is to make it so that there is no border/background color and the text is orange when it is selected instead of white. If you could provide some recommendations for how the code needs to be changed, that is greatly appreciated.
The image below illustrates what it looks like.
nav {
font-family: 'Poppins', sans-serif;
position: sticky;
border: 0;
}
.nav-link {
margin-top: 0em;
margin-left: 1.5em;
font-size: 1.2em;
}
#media screen and (min-width: 768px) {
.nav-link {
margin-top: 1.0em;
margin-left: 1.5em;
font-size: 1.2em;
}
}
.navbar-light .nav-item.active .nav-link,
.navbar-light .nav-item .nav-link:active,
.navbar-light .nav-item .nav-link:focus,
.navbar-light .nav-item:hover .nav-link {
color: #FC9639;
}
.navbar-light .nav-item .nav-link:focus {
background-color: white;
}
.icon-bar {
background-color: #000000 !important;
border: 0;
}
.navbar-light {
background-color: white !important;
border: none !important;
border-width: 0!important;
}
.logo {
margin-left: 25px;
width: 80px;
height: 80px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#3.4.1/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#3.4.1/dist/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-light bg-white navbar-inverse">
<div class="container-fluid">
<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 class="navbar-brand" href="#">WebSiteName</a> -->
<img src="fusebloomLogo.png" alt="FuseBloom logo" class="logo" />
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active nav-item">
<a class="nav-link" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#mission">Mission</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#reviews">Reviews</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#process">Process</a>
</li>
</ul>
</div>
</div>
</nav>
My bootstrap navbar looks like the following:
When I hover over to each of the menu options, it shows an animated underline looks like this:
How can I increase the gap between text and its underline?
Using border instead of underline would solve your problem. Try this code.
ul.ml-auto > li > a > span{
font: 15px Roboto,sans-serif;
font-weight: 500;
position: relative;
display: inline-block;
color: #FFFFFF80;
overflow: hidden;
padding-bottom: 5px;
}
ul.ml-auto > li > a > span::before {
position: absolute;
content: attr(data-content);
color: #00FFFF;
clip-path: polygon(0 0, 0 0, 0% 100%, 0 100%);
transition: clip-path 275ms ease;
display: block;
border-bottom: 1px solid #00FFFF;
padding-bottom: 3px;
}
First you can't modify the spacing when use text-decorate: underline
And your code use <:before>
Cause span is inline style then its spacing just fix with the content inside it.
My solution is make padding for your and <:before> then use border-bottom inside :before tag
ul.ml-auto > li > a > span{
///Adding bottom-padding here
padding-bottom: 3px; // your spacing you want - 1 cause the border will take 1px of the height
}
ul.ml-auto > li > a > span::before {
border-bottom: 1px solid red;
padding-bottom:2px;
}
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Resize</title>
<meta charset="utf-8"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1" ></meta>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
.navbar-custom {
background-color: #484848;
}
ul.ml-auto > li > a > span{
font: 15px Roboto,sans-serif;
font-weight: 500;
position: relative;
display: inline-block;
color: #FFFFFF80;
overflow: hidden;
padding-bottom:2px;
}
ul.ml-auto > li > a > span::before {
position: absolute;
content: attr(data-content);
color: #00FFFF;
border-bottom: 1px solid red;
padding-bottom:2px;
clip-path: polygon(0 0, 0 0, 0% 100%, 0 100%);
transition: clip-path 275ms ease;
}
ul.ml-auto > li > a > span:hover::before {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
</style>
<body>
<nav class="navbar navbar-custom navbar-expand-lg navbar-dark fixed-top" id="mainNav">
<div class="container">
<a style="font: 20px Arial,sans-serif" class="navbar-brand js-scroll-trigger" href="#">HOME</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul style="font: 15px Roboto,sans-serif" class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#about"><span data-content="LOREM">LOREM</span></a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#expertise"><span data-content="LOREM">LOREM</span></a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#portfolio"><span data-content="LOREM">LOREM</span></a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#contact"><span data-content="LOREM">LOREM</span></a>
</li>
</ul>
</div>
</div>
</nav>
</body>
</html>
Here is a sample Html for padding-top and bottom of list in Menu
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<ul class="ml-auto navbar-nav">
<li class="nav-item">
<a class="nav-link" href="">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">About me</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Features</a>
</li>
</ul>
</div>
</nav>
here is the code for underline
li{
text-decoration: underline;
text-underline-position: under;
}
I'm trying to create a double layered navbar, with the top layer having company info like phone, email, social links, etc.
The second layer is the main navbar, which is supposed to be sticky and transparent.
But right now, it's pushing the next div (first) down and creating this blank space instead of hovering on top of the div. I can't really find the fault with it. I'm using Bootstrap 4.
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<nav class="navbar navbar-expand-md navbar-dark bg-transparent sticky-top">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<div class="first"></div>
<div class="second"></div>
A sticky positioned element will take up it's space as it is positioned relatively until it is scrolled past and becomes sticky (then it doesn't say what should happen to that space).
Not sure if what the below is after, but I have just moved the sticky class onto a separate container div and given that a height of 0 with overflow visible, that way it doesn't take up any space
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
.sticky-top {
height:0;
overflow:visible;
box-sizing:border-box;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<div class="sticky-top">
<nav class="navbar navbar-expand-md navbar-dark bg-transparent">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="first"></div>
<div class="second"></div>
https://developer.mozilla.org/en-US/docs/Web/CSS/position
Instead of using sticky-top use fixed-top, the sticky property will maintain the space of the element in the normal flow that is why you see that space..
#top-nav{
position: relative;
z-index: 1000;
}
.top-nav{
background-color: #FFF;
height: 40px;
}
.top-nav a{
color:#696969;
}
.top-nav a:hover{
color:#FF6700;
}
.top-nav p{
margin-left: 50px;
position: relative;
top:5px;
color: #696969;
}
.top-nav .social-links a{
padding-right: 20px !important;
position: relative;
top: 5px;
color: #696969;
}
.top-nav .social-links a:hover{
color: #ff6700;
}
#content{
height:100%;
width:100%;
}
.navbar-brand img{
width: 300px ;
height: auto ;
}
#media screen and (max-width:500px){
.navbar-brand img{
width:250px;
}
#content{
/* top: - */
}
}
#media screen and (min-width: 500px){
.navbar-brand img{
margin-left: 20px;
}
}
.first{
height: 100vh;
background-color: #000;
position: relative;
z-index:0;
/* position:relative;
top:-115px; */
}
.second{
min-height: 100vh;
background-color: #676767;
}
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700%7CRoboto%7CJosefin+Sans:100,300,400,500" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/fa-svg-with-js.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="css/normalise.css">
<link rel="stylesheet" href="css/style.css">
<div id="top-nav" class="container-fluid text-center">
<div class="container row top-nav justify-content-between ml-auto mr-auto">
<div class="call .col-auto mr-auto">
<p><b>Contact: </b>+111111111</p>
</div>
<div class="call .col-auto mr-auto">
<p><b>Email: </b>contact#axyz.com</p>
</div>
<div class="col-auto social-links">
<i class = "fab fa-facebook-f"></i>
<i class = "fab fa-skype"></i>
<i class = "fab fa-linkedin-in"></i>
</div>
</div>
</div>
<nav class="navbar navbar-expand-md navbar-dark bg-transparent fixed-top">
<a class="navbar-brand" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Career</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<div class="first"></div>
<div class="second"></div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="js/fontawesome-all.min.js"></script>
If you want the 2nd navbar background to be transparent, you have to make the sure the color of content in the navbar can be seen over the different background colors...
.sticky-top .navbar-nav .nav-link,
.sticky-top .navbar-nav .active .nav-link {
color: #cc00dd;
}
https://www.codeply.com/go/ypn9gieMza
please help... Underline in my navbar doesn't work. This is my HTML and css file: https://jsfiddle.net/57fd6yf5/1/
I wanted the cursor to active underline under menu, but not under logo. I guessing that the problem is in css file.
HTML:
<nav class="navbar navbar-expand-md navbar-light bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">O MNIE</a>
</li>
<li class="nav-logo">
<img id="logo-navbar" src="images/logo.png" width="60px" height="60px">
</li>
<li class="nav-item">
<a class="nav-link" href="#">PORTFOLIO</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">KONTAKT</a>
</li>
</ul>
</div>
</nav>
CSS:
.nav-link{
font-size: 20px;
}
.nav-item{
padding: 15px 30px;
}
.nav-logo{
padding: 10px 10px
}
.navbar-collapse {
justify-content: center;
}
.navbar-light .navbar-nav .active::after{
position: absolute;
bottom: -10px;
left: 0;
right: 0;
width: 100%
content: " ";
color: #F4C127;
border-bottom: 5px solid #F4C127;
}
.navbar-nav > li {
float: left;
position: relative;
}
For the border-bottom to be under the active link item, you would need the following css rule:
.navbar-light .navbar-nav .active>.nav-link {
border-bottom: 5px solid #F4C127;
}
However, if you want the border to be at the bottom of the entire navbar, then (as #ZimSystem pointed out) you need to add the missing ; to the width: 100% part in your css rule.
You should replace this css. Your class should be .navbar-light .navbar-nav li.active
.navbar-light .navbar-nav li.active::after{
position: absolute;
bottom: -10px;
left: 0;
right: 0;
width: 100%;
content: " ";
color: #F4C127;
border-bottom: 5px solid #F4C127;
}