Navigation bar background image does not expand when resized - html

My navigation bar has an image background, and when I resize screen to the mobile size, when I press the hamburger menu, I want that background image to expand with the menu. Any suggestions how?
If my navbar background is color by default, it expands.
.navbar {
background-image: url('/images/HEADER.png');
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
top: -10px!important;
height: 110px;
}
.navbar-toggler {
outline: none!important;
}
.nav-link {
color: black;
font-family: myriad-pro, sans-serif;
font-weight: 700;
font-style: normal;
text-transform: uppercase;
line-height: 10px;
font-size: 0.8rem;
}
.nav-link:hover {
color: white;
}
<nav class="navbar navbar-expand-lg fixed-top">
<a class="navbar-brand ml-lg-5 pl-5" href="#"><img height=7 0px; class="img-responsive" src="images/logo.png" alt=""></a>
<button class="mb-2 navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<div id = "hamburger">
<div class = "one"></div>
<div class = "one"></div>
<div class = "one"></div>
</div>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto mr-5 pr-5">
<li class="nav-item active">
<a class="nav-link" href="#pagrindinis">Pagrindinis<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#paslaugos">Paslaugos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#portfolio">Atlikti Darbai</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#apie">Apie Mus</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#kontaktai">Kontaktai</a>
</li>
</ul>
</div>
</nav>

Donot restrict the height of the navbar at the start ,that is

Related

How to move dropdown item to the right end of the page

I'm trying to move the language switcher and it's items to the right end of the page. I tried ml-auto but it didn't work.
When I try to move the language picker using padding-left all of its items appear in the center of the page. Any solutions or advices?Here is how my web-page looks like.
.navbar-nav {
margin: 0 auto;
}
.nav-link {
font-weight: 900;
font-size: 1rem;
float: right;
}
#top-nav {
position: absolute;
z-index: 3;
width: 100%;
background-color: transparent !important;
}
#logo {
width: 100px;
height: 50px;
margin-left: 0;
padding-left: 0;
}
.flag-icon {
border-radius: 50%;
}
.navbar-light .navbar-toggler {
color: #FFFFFF;
border-color: #FFFFFF;
}
<nav class="navbar navbar-expand-lg navbar-light bg-light" id="top-nav">
<a class="navbar-brand" id="logo" href="index.html">
<img src="media/logo_light.svg" />
</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="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse " id="navbarNav">
<ul class="navbar-nav">
<li id="main" class="nav-item active ">
<a class="nav-link text-light" href="#">მთავარი<span class="sr-only">(current)</span></a>
</li>
<li id="about-us" class="nav-item">
<a class="nav-link text-light" href="#">ჩვენ შესახებ</a>
</li>
<li id="services" class="nav-item">
<a class="nav-link text-light" href="#">სერვისები</a>
</li>
<li id="contact" class="nav-item">
<a class="nav-link text-light " href="#">კონტაქტი</a>
</li>
<li class="nav navbar-nav nav-item dropdown justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="dropdown09" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="flag-icon flag-icon-ge"></span></a>
<div class="dropdown-menu" aria-labelledby="dropdown09">
<a class="dropdown-item nav-link" href="#gb"><span class="flag-icon flag-icon-gb"></span></a>
<a class="dropdown-item nav-link" href="#ru"><span class="flag-icon flag-icon-ru"> </span></a>
</div>
</li>
</ul>
</div>
</nav>
Do you want something like this?
.navbar-nav {
margin: 0 auto;
}
.nav-link {
font-weight: 900;
font-size: 1rem;
}
#top-nav {
position: absolute;
z-index: 3;
width: 100%;
background-color: transparent !important;
}
#logo {
width: 100px;
height: 50px;
margin-left: 0;
padding-left: 0;
}
.flag-icon {
border-radius: 50%;
}
.navbar-light .navbar-toggler {
color: #FFFFFF;
border-color: #FFFFFF;
}
.navbar-nav {
float: right;
}
<nav class="navbar navbar-expand-lg navbar-light bg-light" id="top-nav">
<a class="navbar-brand" id="logo" href="index.html">
<img src="media/logo_light.svg" />
</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="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse " id="navbarNav">
<ul class="navbar-nav">
<li id="main" class="nav-item active ">
<a class="nav-link text-light" href="#">მთავარი<span class="sr-only">(current)</span></a>
</li>
<li id="about-us" class="nav-item">
<a class="nav-link text-light" href="#">ჩვენ შესახებ</a>
</li>
<li id="services" class="nav-item">
<a class="nav-link text-light" href="#">სერვისები</a>
</li>
<li id="contact" class="nav-item">
<a class="nav-link text-light " href="#">კონტაქტი</a>
</li>
<li class="nav navbar-nav nav-item dropdown justify-content-end">
<a class="nav-link dropdown-toggle" href="#" id="dropdown09" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="flag-icon flag-icon-ge"></span></a>
<div class="dropdown-menu" aria-labelledby="dropdown09">
<a class="dropdown-item nav-link" href="#gb"><span class="flag-icon flag-icon-gb"></span></a>
<a class="dropdown-item nav-link" href="#ru"><span class="flag-icon flag-icon-ru"> </span></a>
</div>
</li>
</ul>
</div>
</nav>
Try adding a class to your language switcher, navbar-right, that used to work on Bootstrap 3, not 100% sure on Bootstrap 4

how to to make a rounded div that fits with a rounded navbar?

I wanna make that red div fit with the corners and the height of the navbar. I have been working with bootstrap components and trying to adapt it to what I want.
if there is a way to use a button instead of a div will be fine too, I just want it to fit with the size of the navbar.
that's what I have right now
that's what I aim for
here is my code snippet
.container {
min-height: 100vh;
padding: 2rem 1rem;
}
.navbar {
z-index: -1;
width: 70%;
margin: 0 auto;
border-radius: 20rem;
}
.nav-item {
padding: 0;
}
.book-now {
overflow: visible;
z-index: 100;
background-color: rgba(255, 48, 48, 1);
height: match-parent;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="container">
<nav class="navbar bg-dark navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="">MOTRAVELS</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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="">CITIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">PLACES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">EVENTS</a>
</li>
<div id="book-now">
<a class="nav-link" href="">BOOK NOW</a>
</div>
</ul>
</div>
</nav>
</header>
May be like this ?
.container {
min-height: 100vh;
padding: 2rem 1rem;
}
.navbar {
z-index: -1;
width: 70%;
margin: 0 auto;
border-radius: 20rem;
}
.nav-item {
padding: 0;
}
.nav-item:last-child {
background-color: rgba(255, 48, 48, 1);
height: match-parent;
border-radius: 0rem 25rem 25rem 0rem;
margin-right: -0.5rem;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<header class="container">
<nav class="navbar bg-dark navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="">MOTRAVELS</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 ml-auto">
<li class="nav-item">
<a class="nav-link" href="">CITIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">PLACES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">EVENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">BOOK NOW</a>
</li>
</ul>
</div>
</nav>
</header>

navbar smaller than navbar-brand

I am looking for a way to have a bigger navbar-brand (bootstrap 4) than the height of the navbar itself. So the navbar-brand should overlap the navbar. Currently it seems that the navbar height is increased to fit the navbar-brand.
My HTML looks like:
<nav class="navbar navbar-expand-lg navbar-custom fixed-top top-menu-4">
<div class="container">
<div class="navbar-brand">
<img src="https://via.placeholder.com/350x170.png" width="350px" height="170px" alt="">
</div>
<button class="navbar-toggler custom-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">
<a class="nav-link" href="none.html">Example 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="none.html">Example 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="none.html">Example 3</a>
</li>
</ul>
</div>
</div>
</nav>
So what I want is something like an overlap:
Give a fixed height to the .navbar and apply transform for .navbar-brand
.navbar {
height: 100px;
background-color: rgba(255, 255,255, 0.9);
}
.navbar-brand {
transform: translateY(calc(50% - 30px));
}
Find the fiddle here
You can set the height of the .navbar to some fixed value and since you're using flexbox on your .container you can align the .nav-brand element to the top of it.
See below for details:
.navbar .container {
height: 100px; /* change this to whatever value you want */
}
.navbar-brand {
align-self: flex-start;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-custom fixed-top top-menu-4">
<div class="container">
<div class="navbar-brand">
<img src="https://via.placeholder.com/350x170.png" width="350px" height="170px" alt="">
</div>
<button class="navbar-toggler custom-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">
<a class="nav-link" href="none.html">Example 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="none.html">Example 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="none.html">Example 3</a>
</li>
</ul>
</div>
</div>
</nav>
You should apply absolute position on your image.
.navbar-brand img {
position: absolute;
top: 10px;
left: 30px;
max-height: 100px;
object-fit: contain;
}
You can simply make the navbar-brand position:absolute...
.navbar-brand {
top:0;
position: absolute;
}
Demo: https://www.codeply.com/go/sJc3uCUL5s

Bootstrap 4 navbar background image is not showing

I tried to use background image in Bootstrap 4 nav bar live attached, and I am finding it difficult. I saw a few code but didn't work.
I tried as well to add a div before the nav bar to see if that will solve it, it still didn't.
I am using Bootstrap 4 Beta 2. What could I be doing wrong?
Topnav
html,
body {
height: 100%;
}
body {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #6c6f73;
font-size: 0.9rem;
background-color: #EEE;
}
.header-feature {
min-height:400px;
background: #201D1D url('assets/img/bg/engineer-background.png');
//background: #222 url('assets/img/bg/engineer-background.png') center center no-repeat;
// background: url('assets/img/bg/engineer-background.png');
background-size: cover;
color: #FFF;
font-size: 0.8rem;
padding: 0.5rem;
}
.header-feature p {
font-size: 1rem;
}
<div class="header-feature ">
<nav class="navbar navbar-expand-lg ">
<a class="navbar-brand" href="#"><img src="assets/img/logo.png" height="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>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#"> <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FOR HR</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">SIGNUP</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">LOGIN</a>
</li>
</ul>
</div>
</nav>
<div class="header-div">
<!-- <img src="assets/img/bg/engineer-background.png" /> -->
<h1>Are you in the groove?</h1>
<p>
Share with us
</p>
Get Started
</div>
</div>

Components going under the navbar

My container elements like paragraphs, header and buttons are going under my navbar. The navbar has the property of fixed-top. I have used previous suggestions from other stackoverflow posts like this (twitter bootstrap navbar fixed top overlapping site). But nothing seems to work for me.Here is my navbar code.
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand text-white" href="#"> Bacon Bacon</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link text-white" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">About Us</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="#">Products</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
My container code
<div class="container-fluid bg-overlay">
<div class="row text-center">
<h1>Loren Inpsum</h1>
<h4>Loren Inpsum Loren Inpsum Loren Inpsum Loren Inpsum </h4>
<button type="button" class="btn btn-primary btn-lg">Get Started</button>
</div>
</div>
My CSS
#media (max-width: 979px) {
body {
padding-top: 70px;
}
}
.navbar {
margin-bottom:0px;
background: #FFFFFF;
border-color: #FFFFFF;
padding-bottom:0px;
}
.bg-overlay {
background: linear-gradient(rgba(0,0,0,.7), rgba(0,0,0,.7)), url("https://unsplash.imgix.net/photo-1416339442236-8ceb164046f8?q=75&fm=jpg&s=8eb83df8a744544977722717b1ea4d09");
background-repeat: no-repeat;
text-align:center;
background-size: cover;
background-position: center center;
color: #fff;
height: 450px;
padding-top: 0px;
}
div.container-fluid bg-overlay{
margin-bottom:30px;
}
The only thing you need to addpadding-top outside of MQ.
body {
padding-top: 60px;
}
#media (max-width: 979px) {
body {
padding-top: 70px;
}
}
.navbar {
margin-bottom:0px;
background: #FFFFFF;
border-color: #FFFFFF;
padding-bottom:0px;
}
.bg-overlay {
background: linear-gradient(rgba(0,0,0,.7), rgba(0,0,0,.7)), url("https://unsplash.imgix.net/photo-1416339442236-8ceb164046f8?q=75&fm=jpg&s=8eb83df8a744544977722717b1ea4d09");
background-repeat: no-repeat;
text-align:center;
background-size: cover;
background-position: center center;
color: #fff;
height: 450px;
padding-top: 0px;
}
div.container-fluid bg-overlay{
margin-bottom:30px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand text-white" href="#"> Bacon Bacon</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link text-white" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">About Us</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="#">Products</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid bg-overlay">
<div class="row text-center">
<h1>Loren Inpsum</h1>
<h4>Loren Inpsum Loren Inpsum Loren Inpsum Loren Inpsum </h4>
<button type="button" class="btn btn-primary btn-lg">Get Started</button>
</div>
</div>