I want the menu to go over the nav bar as on mobile, they tend to be a little large for the viewport. I have tried to make the position on .dropdown-menu relative and absolute with no success on either and set the z-index: 999 and no success. Any advice would be greatly appreciated. Its annoying me to high heaven.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<a class="navbar-brand active" href="https://www.inplaydesign.com/index.html">d|b</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">
<a class="nav-link" href="https://blog.inplaydesign.com">blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/gallery/gallery.html">gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://shop.inplaydesign.com">shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/faq/faq.html">f.a.q.</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact/contact.html">contact</a>
</li>
</ul>
<li>
<button type="button" class="btn btn-outline-dark btn-sml" data-target="#logOut">
<i class="fa fa-power-off"></i> log-out</button>
</li>
</div>
</nav>
</div>
<div class="container carousel-container">
</div>
$(window).on("load", function() {
$('.carousel-container').each(function() {
var $carouselContainer = $(this);
var $carousel = $carouselContainer.find('.carousel').on('slid.bs.carousel', function() {
var targetSlide = $carousel.find('.active').index();
var targetContent = $carouselContainer.find('.slide-content[data-slide="' + targetSlide + '"]').html();
$carouselContainer.find('.carousel-text').html(targetContent);
}).carousel({
interval: false
});
$carouselContainer.find('.carousel-selector').on('click', function() {
var targetSlide = $(this).data('slide');
$carousel.carousel(targetSlide);
});
// The carousel is already at first slide (slide 0).
var n = $carouselContainer.find(".slide-content").length; // number of slides in this carousel
if (n < 2 || $carouselContainer.closest(".modal").length > 0) { // if there are less than 2 slides, or the carousel is in a .modal container
// Trigger the 'slid.bs.carousel' event so its handler can look after the .carousel-text ...
$carousel.trigger('slid.bs.carousel');
} else { // ... else, there are 2 or more slides and this is a non-modal carousel:
// send to last slide
$carousel.carousel(n - 1);
// `slid.bs.carousel` event will be triggered automatically and its handler will look after the .carousel-text.
$carousel.trigger('slid.bs.carousel');
}
});
})
nav {
z-index: 1;
}
button .dropdown-menu {
margin-top: 75px;
position: fixed;
z-index: 9999;
}
.container1 {
position: fixed;
left: 50%;
transform: translate(-51.5%);
z-index: 999;
background-color: black;
}
#container2 {
margin-top: 70px;
}
#thumbnail-view {
transform: translateY(500px);
padding-bottom: 50px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" 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.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<a class="navbar-brand active" href="https://www.inplaydesign.com/index.html">d|b</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">
<a class="nav-link" href="https://blog.inplaydesign.com">blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/gallery/gallery.html">gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://shop.inplaydesign.com">shop</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/faq/faq.html">f.a.q.</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact/contact.html">contact</a>
</li>
</ul>
<li>
<button type="button" class="btn btn-outline-dark btn-sml" data-target="#logOut">
<i class="fa fa-power-off"></i> log-out</button>
</li>
</div>
</nav>
</div>
<div class="container carousel-container">
<div class="container container1" id="container2">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<div class="carousel slide carousel-fade" id="carousel-0">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active carousel-item" data-slide-number="0">
<img class="img-thumbnail" height="450" width="720" height="450" width="720" src="http://via.placeholder.com/720x450">
</div>
</div>
</div>
</div>
<div class="col align-self-center carousel-text"></div>
<div style="display: none;">
<div class="slide-content" data-slide="0">
<h2>Skygate (Night)</h2>
<a href="../downloads/Facebook/skygatenight1fbt.jpg" download>
<button class="btn btn-outline-dark btn-sm" type="button" style="margin-left: -1px;">Facebook Cover</button>
</a>
<div class="btn-group">
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle" data-toggle="dropdown">Desktop</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="../downloads/Desktop/1024x768" download>1024 x 768 (4:3)</a>
<a class="dropdown-item" href="../downloads/Desktop/1600x1200" download>1600 x 1200 (4:3)</a>
<a class="dropdown-item" href="../downloads/Desktop/1280x1024" download>1280 x 1024 (5:4)</a>
<a class="dropdown-item" href="../downloads/Desktop/1366x768" download>1366 x 768 (16:9)</a>
<a class="dropdown-item" href="../downloads/Desktop/1920x1080" download>1920 x 1080 (16:9)</a>
<a class="dropdown-item" href="../downloads/Desktop/1680x1050" download>1680 x 1050 (16:10)</a>
<a class="dropdown-item" href="../downloads/Desktop/1920x1200" download>1920 x 1200 (16:10)</a>
<a class="dropdown-item" href="../downloads/Desktop/2560x1600" download>2560 x 1600 (16:10)</a>
<a class="dropdown-item" href="../downloads/Desktop/2880x1800" download>2880 x 1800 (16:10)</a>
<a class="dropdown-item" href="../downloads/Desktop/3840x2160" download>3840 x 2160 (UHD 16:9)</a>
<a class="dropdown-item" href="../downloads/Desktop/4096x2304" download>4096 x 2304 (4K 16:9)</a>
<a class="dropdown-item" href="../downloads/Desktop/5120x2880" download>5120 x 2880 (5K 16:9)</a>
</div>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle" data-toggle="dropdown">Mobile</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="../downloads/Mobile/iPhone5" download>640 x 1136 (iphone 5)</a>
<a class="dropdown-item" href="../downloads/Mobile/iPhone6" download>750 x 1344 (iphone 6/7)</a>
<a class="dropdown-item" href="../downloads/Mobile/iPhone6+" download>1920 x 1920 (iphone 6+/7+)</a>
<a class="dropdown-item" href="../downloads/Mobile/HTC" download>1080 x 1920 (S4, HTC One)</a>
<a class="dropdown-item" href="../downloads/Mobile/iPad" download>1024 x 1024 (iPad 1&2/Mini)</a>
<a class="dropdown-item" href="../downloads/Mobile/Surface3" download>2160 x 1440 (Surface 3)</a>
<a class="dropdown-item" href="../downloads/Mobile/Retina" download>2048 x 2048 (Retina iPad/Mini)</a>
<a class="dropdown-item" href="../downloads/Mobile/GalaxyS6" download>2560 x 2560 (Galaxy S6)</a>
</div>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle" data-toggle="dropdown">Dual</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="../downloads/Dual/2560x1024" download>2560 x 1024</a>
<a class="dropdown-item" href="../downloads/Dual/3840x1080" download>3840 x 1080</a>
<a class="dropdown-item" href="../downloads/Dual/3360x1050" download>3360 x 1050</a>
<a class="dropdown-item" href="../downloads/Dual/3840x1200" download>3840 x 1200</a>
<a class="dropdown-item" href="../downloads/Dual/5120x1600" download>5120 x 1600</a>
<a class="dropdown-item" href="../downloads/Dual/8192x2304" download>8192 x 2304</a>
<a class="dropdown-item" href="../downloads/Dual/7680x2160" download>7680 x 2160</a>
<a class="dropdown-item" href="../downloads/Dual/10240x2880" download>10240 x 2880</a>
</div>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle" data-toggle="dropdown">Triple</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="../downloads/Triple/3840x1024" download>3840 x 1024</a>
<a class="dropdown-item" href="../downloads/Triple/5760x1080" download>5760 x 1080</a>
<a class="dropdown-item" href="../downloads/Triple/5040x1050" download>5040 x 1050</a>
<a class="dropdown-item" href="../downloads/Triple/5760x1200" download>5760 x 1200</a>
<a class="dropdown-item" href="../downloads/Triple/7680x1600" download>7680 x 1600</a>
<a class="dropdown-item" href="../downloads/Triple/12280x2304" download>11520 x 2160</a>
<a class="dropdown-item" href="../downloads/Triple/12280x2304" download>12288 x 2304</a>
<a class="dropdown-item" href="../downloads/Triple/15360x2880" download>15360 x 2880</a>
</div>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-outline-dark btn-sm dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-apple" aria-hidden="true"></i>
</button>
<div class="dropdown-menu" role="menu">
<h6 class="dropdown-header">Dual Screen</h6>
<a class="dropdown-item" href="../downloads/macOS/dual/2560x1024" download>2560 x 1024</a>
<a class="dropdown-item" href="../downloads/macOS/dual/3840x1080" download>3840 x 1080</a>
<a class="dropdown-item" href="../downloads/macOS/dual/3360x1050" download>3360 x 1050</a>
<a class="dropdown-item" href="../downloads/macOS/dual/3840x1200" download>3840 x 1200</a>
<a class="dropdown-item" href="../downloads/macOS/dual/5120x1600" download>5120 x 1600</a>
<a class="dropdown-item" href="../downloads/macOS/dual/8192x2304" download>8192 x 2304</a>
<a class="dropdown-item" href="../downloads/macOS/dual/7680x2160" download>7680 x 2160</a>
<a class="dropdown-item" href="../downloads/macOS/dual/10240x2880" download>10240 x 2880</a>
<h6 class="dropdown-header">Triple Screen</h6>
<a class="dropdown-item" href="../downloads/macOS/triple/3840x1024" download>3840 x 1024</a>
<a class="dropdown-item" href="../downloads/macOS/triple/5760x1080" download>5760 x 1080</a>
<a class="dropdown-item" href="../downloads/macOS/triple/5040x1050" download>5040 x 1050</a>
<a class="dropdown-item" href="../downloads/macOS/triple/5760x1200" download>5760 x 1200</a>
<a class="dropdown-item" href="../downloads/macOS/triple/7680x1600" download>7680 x 1600</a>
<a class="dropdown-item" href="../downloads/macOS/triple/12280x2304" download>11520 x 2160</a>
<a class="dropdown-item" href="../downloads/macOS/triple/12280x2304" download>12288 x 2304</a>
<a class="dropdown-item" href="../downloads/macOS/triple/15360x2880" download>15360 x 2880</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container animated fadeIn" id="thumbnail-view" data-masonry='{ "itemSelector": ".grid-item", "columnWidth": 150 }'>
<div class="grid">
<div class="grid-item">
<a class="hexLink carousel-selector" data-slide="0">
<img width="150" height="97.5" class="img-thumbnail" src="http://via.placeholder.com/150x97">
</a>
</div>
</div>
</div>
</div>
Make the dropdown's position fixed, adjust the position (right/top) and give it a higher z-index value than the header itself
Related
I created a navbar with Bootstrap. Everything seems okay on big screen but on smaller screen when I click on the toggler icon, the menu does not collapse. I tried multiple things like writing "display: contents;" in the css file, but nothing worked. Can you tell me what am I doing wrong? This is my code:
<nav id="navbar" class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.html"><img src="images/logo.png" width="100"></a>
<button class="navbar-toggler" 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>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<!-- home -->
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.html" style="margin-left: 20px">Home</a>
</li>
<!--- women --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown" id="navbarDropdown" role="button" data-toggle="dropdown" aria-expanded="false">
Women
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Clothes</a>
<a class="dropdown-item" href="#">Accessories</a>
<a class="dropdown-item" href="#">Shoes</a>
</div>
</div>
</li>
<!--- men --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown" id="navbarDropdown" role="button" data-toggle="dropdown" aria-expanded="false">
Men
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Clothes</a>
<a class="dropdown-item" href="#">Accessories</a>
<a class="dropdown-item" href="#">Shoes</a>
</div>
</div>
</li>
<!--- help --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown" id="navbarDropdown" role="button" data-toggle="dropdown" aria-expanded="false">
Help
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="sizes.html">Sizes</a>
<a class="dropdown-item" href="faqs.html">FAQs</a>
<a class="dropdown-item" href="contact-us.html">Contact Us</a>
<a class="dropdown-item" href="about-us.html">About Us</a>
</div>
</div>
</li>
<!-- search box -->
<form class="form-inline">
<input class="form-control rounded" type="search" placeholder="What are you looking for?" aria-label="Search" size=60px style="text-align: left;">
<button type="submit" class="btn btn-outline-dark" style="margin-left: 5px"><i class="bi bi-search"></i></button>
</form>
<!-- shopping cart -->
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="cart.html">
<i class="bi bi-bag" style="font-size: 30px; margin-left: 650px;"></i>
<span class="cart-basket d-flex align-items-center justify-content-center">
0
</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
Add CSS
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<body>
<nav id="navbar" class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.html"><img src="images/logo.png" width="100"></a>
<button class="navbar-toggler" 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>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<!-- home -->
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.html" style="margin-left: 20px">Home</a>
</li>
<!--- women --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Women
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Clothes</a>
<a class="dropdown-item" href="#">Accessories</a>
<a class="dropdown-item" href="#">Shoes</a>
</div>
</div>
</li>
<!--- men --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Men
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Clothes</a>
<a class="dropdown-item" href="#">Accessories</a>
<a class="dropdown-item" href="#">Shoes</a>
</div>
</div>
</li>
<!--- help --->
<li class="nav-item dropdown">
<div class="dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Help
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="sizes.html">Sizes</a>
<a class="dropdown-item" href="faqs.html">FAQs</a>
<a class="dropdown-item" href="contact-us.html">Contact Us</a>
<a class="dropdown-item" href="about-us.html">About Us</a>
</div>
</div>
</li>
<!-- search box -->
<form class="form-inline">
<input class="form-control rounded" type="search" placeholder="What are you looking for?" aria-label="Search" size=60px style="text-align: left;">
<button type="submit" class="btn btn-outline-dark" style="margin-left: 5px"><i class="bi bi-search"></i></button>
</form>
<!-- shopping cart -->
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="cart.html">
<i class="bi bi-bag" style="font-size: 30px; margin-left: 650px;"></i>
<span class="cart-basket d-flex align-items-center justify-content-center">
0
</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
</body>
Add script file in bottom of the page
I am making a responsive navigation bar and I encountered a problem. Fixed navbar is correct and works fine. It changes transparency when scrolled, but I don't want the hamburger menu (when the device is small) to be fixed in place. How can I change from fix? What attribute should I changed? I am using bootstrap for this. Thank you!
$(function() {
$(window).on('scroll', function() {
if ($(window).scrollTop() > 10) {
$('.navbar').addClass('active');
} else {
$('.navbar').removeClass('active');
}
});
});
function scrollValue() {
var navbar = document.getElementById('navbar');
var scroll = window.scrollY;
if (scroll < 200) {
navbar.classList.remove('BgColour');
} else {
navbar.classList.add('BgColour');
}
}
window.addEventListener('scroll', scrollValue);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header class="header">
<div id="navbar" class="navbar">
<nav class="navbar navbar-expand-lg fixed-top bg">
<img src="images/logo.png" class="img-fluid" id="weblogo" onclick="submitToPage1();" alt="Image Not Found">
VITALY TEA
<div class="container-fluid">
<button type="button " data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler navbar-toggler-right navbar-static-top container-hamburger "><i class="fa fa-bars"></i></button>
<div id="navbarSupportedContent" class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto ">
<li class="nav-item dropdown" id="navbtn">
<a class="nav-link dropdown-toggle" href="#Services" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="submitToPage2();">
Services
<span class="sr-only">(current)</span></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink" id="subnav">
<a class="dropdown-item" href="#">Digital Printing</a>
<a class="dropdown-item" href="#">Binding</a>
<a class="dropdown-item" href="#">Laminating</a>
<a class="dropdown-item" href="#">Cutting</a>
</div>
</li>
<li class="nav-item dropdown" id="navbtn">
<a class="nav-link dropdown-toggle" href="#Menu" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="submitToPage3();"> Menu
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink" id="subnav2">
<a class="dropdown-item" href="#">Warm Drinks</a>
<a class="dropdown-item" href="#">Cold Drinks</a>
<a class="dropdown-item" href="#">Sandwiches</a>
</div>
</li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Orderr" onclick="submitToPage4();">
Order </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#About" onclick="submitToPage5();">
About </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Contact" onclick="submitToPage6();">
Contact </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Link" onclick="submitToPage7();"> Link
</a> </li>
</ul>
</div>
</div>
</nav>
</div>
</header>
The menu on a laptop or desktop is like I want it to be, however on a small screen, I'm 'losing' to options; the search icon and the translate menu. What I would like to achieve is that the logo, the search icon, and the translate bar, and the hamburger menu, are in line with each other. Alternatively, an input field on the second line below the logo and the hamburger menu is workable too.
So far I have been working with the various Bootstrap nav bar components, but have not managed to get it right. In the code below there is also some smarty used, but I don't think that's of any impact on the solution.
Hope someone can point me in the right direction to take it a step further.
Thanks!
<nav class="navbar navbar-color-on-scroll navbar-expand-lg fixed-top scrolling-navbar navbar-transparent" color-on-scroll="170">
<div class="container-fluid">
<div class="navbar-header">
</div>
<div class="navbar-translate">
{* requires popper.js rel="tooltip" *}
{if $page_alias == 'hanse_311'}
<a class="navbar-brand" href="{root_url}" rel="noreferrer" title="{$sitename} | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="logo" alt="{$sitename}" src="{CGSmartImage src="{uploads_url}/images/cms/Logo_Hanse_UisgeBeatha.png" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=1}" height="90vh"/></a>
{else}
<a class="navbar-brand" href="{root_url}" rel="noreferrer" title="{$sitename} | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="logo" alt="{$sitename}" src="{CGSmartImage src="logo_1.jpg" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=0}" height="90vh"/></a>
{/if}
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar top-bar"></span>
<span class="navbar-toggler-bar middle-bar"></span>
<span class="navbar-toggler-bar bottom-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbarNav" data-nav-image="{CGSmartImage src="logo_2.jpg" alt="{$sitename}" title="{$sitename}" noresponsive='1' notag=1 noembed=0}" data-color="orange"}
{Navigator action='default' template="{#theme_resource#}navigator_navigation_multilevel_bootstrap_menu.tpl"}
<form class="form-inline ml-auto text-dark" data-background-color="#990000">
{if $browser_lang != 'nl'}
<div class="form-group my-md-2 col-sm-9">
{include file='cms_template:google_Translate'}
</div>
{/if}
<div class="form-group col-sm-3">
{svg use="search"}
</div>
</form>
</div>
</div>
</nav>
As per request to add some HTML, first the header:
<div class="page-header page-header-small">
<div class="page-header-image" style="background-image: url('data:image/jpeg;base64,.........;">
</div>
<div class="content-center">
<div class="row">
<div class="col-md-8 ml-auto mr-auto">
<div class="rellax" data-rellax-speed="-3" style="transform: translate3d(0px, 0px, 0px);">
<h1 class="title">Downloads</h1>
</div>
<h4>
Downloaden van (technische) bootdocumenten
</h4>
<nav aria-label="breadcrumb" role="navigation">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="text-info">U bent hier: </li>
<li class="breadcrumb-item">
<a href="https://develop.some-site.eu/" title="Home">
Home
</a>
</li>
<li class="breadcrumb-item">
Links
</li>
<li class="breadcrumb-item active" aria-current="page">Downloads</li>
</ol>
</nav>
</nav>
</div>
</div>
</div>
</div>
And the code from menu from while in small screen mode
<nav class="navbar navbar-color-on-scroll navbar-expand-lg fixed-top scrolling-navbar navbar-transparent" color-on-scroll="170"><div class="container-fluid">
<div class="navbar-header"></div>
<div class="navbar-translate">
<a class="navbar-brand" href="https://develop.some-site.eu" rel="noreferrer" title="some site | Design based on Now_UI-Kit." data-placement="bottom" target="_blank"><img id="header-logo" class="largeLogo" alt="some site" src="data:image/png;base64,......">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="https://develop.some-site.eu/">Home</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">Boot en Schipper</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/afkomst-naam">Afkomst naam</a>
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/dehler-36-jv">Dehler 36 JV</a>
<a class="dropdown-item" href="https://develop.some-site.eu/boot-en-schipper/hanse_311">Hanse 311</a>
</div>
</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">Logboek</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/logboek_categorie/logboek_artikelen">Artikelen</a>
<a class="dropdown-item" href="https://develop.some-site.eu/logboek_categorie/gps-tracks">GPS Tracks</a>
</div>
</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">Media</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/fotos-en-videos-rondom-some-site/fotoalbums">Fotoalbums</a>
<a class="dropdown-item" href="https://develop.some-site.eu/fotos-en-videos-rondom-some-site/youtube">Youtube</a>
</div>
</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">Links</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="https://develop.some-site.eu/links-downloads/downloads">Downloads</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="https://develop.some-site.eu/gastenboek">Gastenboek</a>
</li>
</ul>
<form class="form-inline ml-auto text-dark" data-background-color="#990000">
<div class="form-group my-md-2 col-sm-9">
<div id="google_translate_element"></div>
</div>
<div class="form-group col-sm-3">
<svg preserveAspectRatio="none" class="icon icon-search"><use xlink:href="#icon-search"></use></svg>
</div>
</form>
</div>
</div>
</nav>
Site on the development environment, if you resize, you see what I mean and try to achieve development site
Bootstrap navbar-fixed-top not working
I dont have any other styling applied to the nav
I have tried adding a high z-indxs to the nav element and a lower one to the body but still no joy?
<header>
<nav class="navbar navbar-fixed-top navbar-expand-lg navbar-light">
<div class="container-fluid kaki">
<a class="navbar-brand" href="#">Quinta Dos Brejos</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">
<li class="nav-item active">
<a class="nav-link" href="../index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="local amenities\local.html" target="_blank">Places of interest</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../GettingAround/GettingAround.html" target="_blank">Getting Around</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../Gallery/Gallery.html" target="_blank">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.thealgarvetraveller.com" target="_blank">Transfers/Tours</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
try this sample code?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<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-fluid">
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-expand-lg navbar-light bg-light static-top">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="navbar-toggler-icon"></span>
</button> <a class="navbar-brand" href="#">Brand</a>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Link <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="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown">Dropdown link</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider">
</div> <a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
<form class="form-inline">
<input class="form-control mr-sm-2" type="text" />
<button class="btn btn-primary my-2 my-sm-0" type="submit">
Search
</button>
</form>
<ul class="navbar-nav ml-md-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Link <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown">Dropdown link</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider">
</div> <a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="jumbotron">
<h2>
Hello, world!
</h2>
<p>
Now your navbar is fixed
</p>
<p>
<a class="btn btn-primary btn-large" href="#">Learn more</a>
</p>
</div>
</div>
</div>
</div>
i had tried a lot not get a solution for this can u please help with this..actually im setting it by giving by minimum width to the dropdown menu but when in case of responsive and when menu item contains big words the menu items are expanding to out of the box.
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav id="navbar-two" class="navbar-nav navbar-toggleable-md mb-4">
<button class="navbar-toggler navbar-toggler-right" 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="nav navbar-two-list mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">My Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">You & Peers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Family</a>
</li>
</ul>
<div class="mt-2 mt-md-0">
<ul class="nav">
<li class="nav-item">
<button class="btn btn-success dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Add Mutual Funds<sub><i class="fa fa-angle-down" aria-hidden="true"></i></sub></button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
I think you should put the button and dropdown together in a col and use btn-block so it always fill the column. Then you can resize the column responsively.
Demo: http://www.codeply.com/go/OE4tnyG1lt
<div class="container-fluid">
<div id="navbar-two">
<div class="row">
<div class="col-sm-8 col-md-9">
<ul class="nav navbar-two-list">
<li class="nav-item">
<a class="nav-link" href="#">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">My Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">You & Peers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Family</a>
</li>
</ul>
</div>
<div class="col-sm-4 col-md-3">
<ul class="nav">
<li class="col-12 px-0">
<button class="btn btn-success btn-block dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Add Mutual Funds<sub><i class="fa fa-angle-down" aria-hidden="true"></i></sub></button>
<div class="dropdown-menu w-100">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
Demo: http://www.codeply.com/go/OE4tnyG1lt
You can use following code to set the width for both dropdown and button.just change the size of width
.dropdown-menu {
width: 100%;
}
.btn{
width: 100%;
}
You can use media queries. like,
#media only screen and (max-width: 768px) {
.dropdown-menu{
min-width: 400px;
}
}
#media only screen and (max-width: 480px) {
.dropdown-menu{
min-width: 320px;
}
}
You could clip the overflow when the text of the menu items gets too long:
.dropdown-item {
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
Note with the ellipsis property, overflowed content is indicated to the user with dots instead of just hard clipping the content