Disable link decoration on a logo - html

.nav-d a{
display: block;
color: black;
text-decoration: none;
border-bottom: 3px solid transparent;
}
.nav-d a:hover {
border-bottom: 3px solid #262262;
}
.nav-d a.active {
border-bottom: 3px solid #262262;
}
<div class="container nav-d" style="max-width: 1134px;">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand mr-5" href="home.html"><img src="Logo-transparant.png" alt="Logo-transparant"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<li class="nav-item active pr-4">
<a class="nav-link" href="home.html" > Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Nieuwefietsen.html">Nieuwe fietsen</a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Tweedehandsfietsen.html">Tweedehands fietsen</a>
</li>
<li class="nav-item pr-5">
<a class="nav-link" href="Fietsreperatie.html">Fietsreperatie</a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Contact.html">Contact</a>
</li>
<li class="nav-itme pr-0" style= "border:2px solid rgb(47, 47, 112); border-radius: 250px; background-color: rgb(47, 47, 112);">
<a class="nav-link my-link disabled ml-3 mr-2 " herf="home.html" style="color:white; font-size: 16px;"><i class="far fa-phone mr-2"></i>06 20453640</a>
</li>
</nav>
</div>
Disable link decoration on the logo (the bottom underline decoration). i want to get rid of it i tried text-decoration: none; that didn't help.

Try this instead
You HTML Code is invalid there is not <ul> tag before <li>
.nav-d a.navbar-brand:hover{
border-bottom-color:transparent;
}
.nav-d a{
display: block;
color: black;
text-decoration: none;
border-bottom: 3px solid transparent;
}
.nav-d a:hover {
border-bottom: 3px solid #262262;
}
.nav-d a.active {
border-bottom: 3px solid #262262;
}
.nav-d a.navbar-brand:hover{
border-bottom-color:transparent;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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>
<div class="container nav-d" style="max-width: 1134px;">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand mr-5" href="home.html"><img src="Logo-transparant.png" alt="Logo-transparant"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<ul class="navbar-nav">
<li class="nav-item active pr-4">
<a class="nav-link" href="home.html" > Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Nieuwefietsen.html">Nieuwe fietsen</a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Tweedehandsfietsen.html">Tweedehands fietsen</a>
</li>
<li class="nav-item pr-5">
<a class="nav-link" href="Fietsreperatie.html">Fietsreperatie</a>
</li>
<li class="nav-item pr-4">
<a class="nav-link" href="Contact.html">Contact</a>
</li>
<li class="nav-itme pr-0" style= "border:2px solid rgb(47, 47, 112); border-radius: 250px; background-color: rgb(47, 47, 112);">
<a class="nav-link my-link disabled ml-3 mr-2 " herf="home.html" style="color:white; font-size: 16px;"><i class="far fa-phone mr-2"></i>06 20453640</a>
</li>
</ul>
<div>
</nav>
</div>

Do something like this:
a {
color:inherit;
text-decoration: none;
}

Try This. That's it.
.nav-d a.navbar-brand:hover{border-bottom:none;}

Related

How can I make a tab from a navbar to fill all the vertical space with bootstrap5?

I used a bootstrap navbar, I created a hover effect and the problem is that when I click on a tab, the color changes in white but there is still a black margin.
Here is how it looks like:
how it is
And here is how I want it to look like:
how it should be
Here is the code:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">Elegant<i class="fa fa-square"></i></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="#homepage">HOMEPAGE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">PAGE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FEATURE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">PRICING</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">BLOG</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fa-solid fa-magnifying-glass"></i></a>
</li>
</ul>
</div>
</div>
</nav>
CSS
.nav-item a {
font-size: 12px;
color: white;
letter-spacing: 2.5px;
padding: 25px !important;
display: block;}
.nav-item a:hover {
background-color: white;
color: black;}
Make the padding of the relevant container to be 0, that is the navbar.
.nav-item a {
font-size: 12px;
color: white;
letter-spacing: 2.5px;
padding: 25px !important;
display: block;
}
.nav-item a:hover {
background-color: white;
color: black;
}
.navbar {
--bs-navbar-padding-y: 0;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">Elegant<i class="fa fa-square"></i></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="#homepage">HOMEPAGE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">PAGE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FEATURE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">PRICING</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">BLOG</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><i class="fa-solid fa-magnifying-glass"></i></a>
</li>
</ul>
</div>
</div>
</nav>

Bootstrap Navbar, background to only be on the right and not the entire width

Using bootstrap's navbar, I'm only using the dropdown toggler icon on the right. I want a background with a width that covers only the right portion and not the entire width. Any insight would be appreciated.
Attempts 1 and 2:
Trying to get:
.menu {
font-family: header;
color: white !important;
font-size: 3rem;
background-color: rgba(0, 0, 0, 0.3);
}
.menu-bg {
background-color: rgba(0, 0, 0, 0.3);
}
body {
background: #333 !important;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<nav class="navbar navbar-dark fixed-top pt-md-5 pe-md-5 pt-2 pe-2">
<div class="container-fluid">
<button class="navbar-toggler ms-auto custom-toggler menu collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> MENU
</button>
<div class="collapse navbar-collapse menu-items" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 menu-bg">
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#features">FEATURES</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#counter">SHARK COUNTER</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#about">ABOUT US</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#faq">FAQ</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3 rounded-bottom" href="#">BACK TO TOP</a>
</li>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
Kindly try
.menu-bg {
width: 250px;
}
Here is a working example. The gist is to use position:absolute and set width to dropdown so that it will stick to the right.
.menu {
font-family: header;
color: white !important;
font-size: 3rem;
background-color: rgba(0, 0, 0, 0.3);
}
.menu-bg {
background-color: rgba(0, 0, 0, 0.3);
}
#navbarSupportedContent {
width:150px;
position: absolute;
right:0px;
top:100%;
}
.dropdown-wrap {
position: relative;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<nav class="navbar navbar-dark fixed-top pt-md-5 pe-md-5 pt-2 pe-2">
<div class="container-fluid">
<div class="row">
<div class="col-xs-10"></div>
<div class="col-xs-2 dropdown-wrap">
<button class="navbar-toggler ms-auto custom-toggler menu collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> MENU
</button>
<div class="collapse navbar-collapse menu-items" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 menu-bg">
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#features">FEATURES</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#counter">SHARK COUNTER</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#about">ABOUT US</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3" href="#faq">FAQ</a>
</li>
<li class="nav-item ms-auto">
<a class="nav-link pe-3 rounded-bottom" href="#">BACK TO TOP</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
Working JSfiddle
Only:
.menu-bg {
background-color: rgba(0, 0, 0, 0.3);
display: inline-block;
}

Bootstrap 4 - How to prevent collapsing menu from collapsing all elements in the nav

I'm using a bootstrap 4 navbar and I want to prevent the logo and language switch from moving and collapsing with the menu when the hamburger menu is clicked. Here is all of my code. Also, here is the link to my codepen. Is this possible?
https://codepen.io/asizemore/pen/LYEgvOy?editors=1100
CSS
.logo {
max-width: 130px;
}
.btn {
font-family: 'Muli', sans-serif;
font-weight: 900;
}
.btn {
background: rgb(142, 63, 41);
color: rgb(202, 171, 159);
}
.active {
background: rgb(166, 73, 47);
color: white;
}
HTML
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<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>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
!-- NAV BAR -->
<nav class="navbar navbar-light fixed-top navbar-expand-lg bg-white">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand mt-lg-0" href="#"><img src="https://via.placeholder.com/200x50" class="logo img-fluid"></a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mx-auto mt-2 mt-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">PURPOSE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FAMILY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">AGRICULTURE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ART</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
<!-- LANGUAGE SWITCH -->
<div class="btn-group btn-toggle lang mr-1">
<input type="button" name="lang" class="btn" value="ENG">
<input type="button" name="lang" class="btn active" value="SPA">
</div>
</nav>
Place your language switch inside a .navbar-item, right after .navbar-brand and give it an order: 1 (which is bigger than the default of 0 - so it's going to be displayed as the last item of its parent) on the interval at which your .navbar is not collapsed. Since you're using .navbar-expand-lg, it's going to be #media (min-width: 992px) but if you used .navbar-expand-md it would have been min-width: 768px - or 576px for -sm. More about responsive breakpoints here.
When the nav is collapsed, you don't need the order changed, so the language switcher is displayed before the menu (that's the reason we placed it after the logo in the first place). See it working:
.logo {
max-width: 130px;
}
.btn {
font-family: 'Muli', sans-serif;
font-weight: 900;
}
.btn {
background: rgb(142, 63, 41);
color: rgb(202, 171, 159);
}
.active {
background: rgb(166, 73, 47);
color: white;
}
#media(min-width: 992px) {
.language-switch {
order: 1;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<nav class="navbar navbar-light fixed-top navbar-expand-lg bg-white">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand mt-lg-0" href="#"><img src="https://via.placeholder.com/200x50" class="logo img-fluid"></a>
<div class="nav-item language-switch">
<div class="btn-group btn-toggle lang mr-1">
<input type="button" name="lang" class="btn" value="ENG">
<input type="button" name="lang" class="btn active" value="SPA">
</div>
</div>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mx-auto mt-2 mt-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">PURPOSE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FAMILY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">AGRICULTURE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ART</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
Oh, and you need to come up with an solution on how to align the three (logo, language switch and toggler) when they don't actually fit in one line (devices narrower than ~450px). But that's a problem you basically asked for.
Note: if you want the logo to be displayed first when navbar is collapsed, you could simply place it before the toggler and give the toggler either ml-auto mr-3 or ml-3 mr-auto to make it stick to either right or left side (having it centered would be sort of weird, IMHO). Example:
.logo {
max-width: 130px;
}
.btn {
font-family: 'Muli', sans-serif;
font-weight: 900;
}
.btn {
background: rgb(142, 63, 41);
color: rgb(202, 171, 159);
}
.active {
background: rgb(166, 73, 47);
color: white;
}
#media(min-width: 992px) {
.language-switch {
order: 1;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
!-- NAV BAR -->
<nav class="navbar navbar-light fixed-top navbar-expand-lg bg-white">
<a class="navbar-brand mt-lg-0" href="#"><img src="https://via.placeholder.com/200x50" class="logo img-fluid"></a>
<button class="navbar-toggler mr-auto" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="nav-item language-switch">
<div class="btn-group btn-toggle lang mr-1">
<input type="button" name="lang" class="btn" value="ENG">
<input type="button" name="lang" class="btn active" value="SPA">
</div>
</div>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mx-auto mt-2 mt-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">PURPOSE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FAMILY</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">AGRICULTURE</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ART</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
The same result could be achieved by using order: -1 on the logo (without switching its place in DOM with the toggler) on the proper responsive interval (i.e: below 991px in your case).

How do I collapse a navbar for mobile devices?

.navbar {
background:white;
border: 1px solid #008080;
border-width: 1px 0;
box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.75), 0 8px 6px -6px black;
}
.navbar-contact,
.nav {
background: #008080;
overflow: hidden;
}
.navbar-contact {
max-height: 29px;
}
.bottom {
margin-top: -30px;
}
/* White Angles (Common) */
.nav:before,
.navbar-contact:after {
content: "";
background: #fff;
position: absolute;
width: 2em; height: 4em;
transform: rotate(30deg);
}
/* .navbar-contact angle position */
.navbar-contact:after {
right: -1em;
top: -0.5em;
}
/* .nav angle position */
.nav:before {
left: -1em;
top: -1em;
}
.head-text{
padding-top:1px;
font-family:Righteous;
text-align:center;
color:#78ece9;
}
<html>
<head>
<title>Contact</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="http://computervision.in/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="http://computervision.in/css/style.css" rel="stylesheet">
</head>
<!------ Include the above in your HEAD tag ---------->
<body id="top">
<nav class="navbar p-0 fixed-top">
<div class="top d-flex w-100">
<div class="px-2 navbar-contact text-white position-relative flex-grow-1">Contact: <a class="text-white" href="#">+91 xxxxxxxxxx or + 91 xxxxxxxxxx </a></div>
<div class="pt-1 pr-3 d-flex mt-auto bg-white position-relative">
<div class="dropdown">
<img class="position-relative" src="http://computervision.in/images/IN.png" height="50">
<div class="dropdown-content2">
<a class="my-font" href="courses.php">Courses</a>
<a class="my-font" href="login.php">Student Login</a>
<a class="my-font" href="#">Make Payments</a>
<a class="my-font" href="#">Student Review</a>
<a class="my-font" href="#">Verify Certificates</a>
<a class="my-font" href="#">Online Registration</a>
</div>
</div>
<div class="dropdown">
<img class="position-relative ml-3 mr-2" src="http://computervision.in/images/PV.png" height="55">
<div class="dropdown-content">
<a class="my-font" href="#">Gallery</a>
<a class="my-font" href="#">Hot Jobs</a>
<a class="my-font" href="#">Placement Cell</a>
<a class="my-font" href="#">Top Placements</a>
<a class="my-font" href="#">Placement Drive</a>
<a class="my-font" href="placement.php">Placement Testimonials</a>
</div>
</div>
</div>
</div>
<div class="bottom d-flex w-100">
<div class="navbar-brand">
<a class="navbar-brand mr-0" href="#"> <img src="http://computervision.in/images/logo.png" height="60"> </a>
<button class="navbar-toggler" id="nav1" type="button" data-toggle="collapse" data-target="#navMain" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<ul class="nav mt-auto flex-grow-1 pl-4 position-relative" role="navigation" id="navMain">
<li class="nav-item active"><a class="nav-link my-font" href="index.php">Home</a></li>
<li class="nav-item"><a class="nav-link my-font" href="about.php">About</a></li>
<li class="nav-item "><a class="nav-link my-font" href="why.php">Why Computer Vision</a></li>
<li class="nav-item"><a class="nav-link my-font" href="courses.php">Courses</a></li>
<li class="nav-item"><a class="nav-link my-font" href="services.php">Services</a></li>
<li class="nav-item"><a class="nav-link my-font" href="events.php">Events</a></li>
<li class="nav-item"><a class="nav-link my-font" href="blogs.php">Blogs</a></li>
<li class="nav-item"><a class="nav-link my-font blink" href="contact.php">Contact</a></li>
<li class="nav-item"><a class="nav-link my-font" href="register.php">Register</a></li>
</ul>
</div>
</nav>
<!-- Contact Us Section -->
</body>
</html>
I have tried a lot of codes for This Code in order to make it responsive in mobile devices, so that when a user accesses my page from mobile he gets a collapsed navigation bar. I have tried in every way, the navbar collapse class doesn't even seem to work. so I have removed the whole code for collapsing the navbar. Please help me out, i've been stuck in here for many days. Thanks anyways.
.navbar {
border: 1px solid #008080;
border-width: 1px 0;
box-shadow: 0px -4px 3px rgba(50, 50, 50, 0.75), 0 8px 6px -6px black;
}
.navbar-contact,
.nav, .navbar-nav {
background: #008080;
overflow: hidden;
}
.navbar-contact {
max-height: 29px;
}
.bottom {
margin-top: -30px;
}
/* White Angles (Common) */
.nav:before,
.navbar-contact:after {
content: "";
background: #fff;
position: absolute;
width: 2em; height: 2.5em;
transform: skew(-30deg);
}
/* .navbar-contact angle position */
.navbar-contact:after {
right: -1em;
top: 0;
}
/* .nav angle position */
.nav:before {
left: -1em;
top: 0;
}
.navbar.navbar-expand-lg {
flex-wrap: wrap;
}
.navbar-toggler {
color: rgba(0,0,0,.5);
border-color: rgba(0,0,0,.1);
}
.navbar .bottom.d-flex {
flex-wrap: wrap;
}
.navbar-toggler-icon {
border:1px solid #ddd;
background-image: url("data:image/svg+xml,<svg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'><path stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/></svg>");
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg p-0">
<div class="top d-flex w-100">
<div class="px-2 navbar-contact text-white position-relative flex-grow-1">Contact: <a class="text-white" href="#">+91 xxxxxxxxxx or xxxxxxxxxx </a></div>
<div class="pt-1 pr-3 d-flex mt-auto bg-white position-relative">
<img class="position-relative" src="http://computervision.in/images/IN.png" height="50">
<img class="position-relative ml-3 mr-2" src="http://computervision.in/images/PV.png" height="55">
</div>
</div>
<div class="bottom d-flex w-100">
<a href="" class="navbar-brand mr-0">
<img src="http://computervision.in/images/logo.png" height="60">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav flex-grow-1 pl-4 position-relative">
<li class="nav-item active"><a class="nav-link text-white active" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link text-white" href="#">Services</a></li>
<li class="nav-item"><a class="nav-link text-white" href="#">Courses</a></li>
<li class="nav-item"><a class="nav-link text-white" href="#">Events</a></li>
<li class="nav-item"><a class="nav-link text-white" href="#">Blogs</a></li>
</ul>
</div>
</div>
</nav>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</body>
</html>
You just have to modify CSS as per your design. Hope this will work for you.
here is small example for a collapsing navbar. Please give it a try. Run the snippet in the post and fullscreen to see how it works.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-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="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>

Bootstrap 4 Navbar changes

These are probably really simple questions, but it has me a bit stumped the CSS;
How can i make the green background (on a nav-item hover) take up the full height of the navbar?
Additionally, when the navbar is collapsed (for small/mobile screens) how can i center the nav-item text & add a border-bottom for the nav-item?
Here's my HTML
<nav class="js-navbar-scroll navbar navbar-expand-lg navbar-light fixed-top navbar-custom">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="img/logo-design-new.png" alt="JDC Support" style="width: 40px;" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggler">
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="about">About</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="photos">Photos</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="collections">Collections</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="careers">Careers</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
Here's my CSS:
.navbar-custom {
background-color: #fff !important;
border-bottom: 2px solid #f1f1f1 !important;
}
.navbar-custom .container-fluid .nav-item.active .nav-link,
.navbar-custom .container-fluid .nav-item:hover .nav-link {
color: #ffffff;
background-color: green;
}
And here's a Plunker of it;
Bootstrap Navbar
First of all you need to add jquery before bootstrap js and add this custom css for what you want
/* Styles go here */
.navbar-custom {
background-color: #fff !important;
border-bottom: 2px solid #f1f1f1 !important;
}
/* change the color of active or hovered links */
.navbar-custom .container-fluid .nav-item.active .nav-link,
.navbar-custom .container-fluid .nav-item:hover .nav-link {
color: #ffffff;
background-color: green; /* add background-color to active links */
}
<link data-require="bootstrap#4.1.3" data-semver="4.1.3" rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
<script data-require="jquery#3.2.1" data-semver="3.2.1" src="https://cdn.jsdelivr.net/npm/jquery#3.2.1/dist/jquery.min.js"></script>
<script data-require="bootstrap#4.1.3" data-semver="4.1.3" src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<style type="text/css">
.navbar-custom{
padding-top:0rem;
padding-bottom:0rem;
}
.nav-link {
display: block;
padding: 1rem 1rem;
}
#media (max-width: 991px){
.navbar-custom{
padding-top:0.5rem;
padding-bottom:0.5rem;
}
.nav-link {
display: block;
padding: 0.5rem 1rem;
}
.navbar-light .navbar-nav .nav-link {
text-align:center;
}
.navbar-light .navbar-nav .nav-item {
border-bottom:5px solid #000000;
}
}
</style>
<nav class="js-navbar-scroll navbar navbar-expand-lg navbar-light fixed-top navbar-custom">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="img/logo-design-new.png" alt="JDC Support" style="width: 40px;" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggler">
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="about">About</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="photos">Photos</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="collections">Collections</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="careers">Careers</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
You can used below code for nav-item hover and text-center nad boredr-bottom for small/mobile screens.
.nav-item:hover{
background-color:green;
}
.collapse.show{
text-align:center;
}
.collapse.show .nav-item{
border-bottom:1px solid black;
}
Please show this link for that. https://jsfiddle.net/DharaSumitPatel/8h1cwezq/
Try changing your css with this
<style>
.navbar-custom {
background-color: #fff !important;
border-bottom: 2px solid #f1f1f1 !important;
padding:0px;
margin:0px;
}
.navbar-custom .container-fluid .nav-item.active .nav-link,
.navbar-custom .container-fluid .nav-item:hover .nav-link {
color: #ffffff;
background-color: green;
border:2px solid green;
}
#navbarToggler.show{
text-align:center;
}
#navbarToggler.show
.nav-item{
border-bottom:1px solid gray;
}
</style>
<nav class="js-navbar-scroll navbar navbar-expand-lg navbar-light fixed-top navbar-custom">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="img/logo-design-new.png" alt="JDC Support" style="width: 40px;" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggler">
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="about">About</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="photos">Photos</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="collections">Collections</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="careers">Careers</a>
</li>
<li class="nav-item mr-4 mb-2 mb-lg-0">
<a class="nav-link" href="contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>