<nav class="navbar navbar-toggleable-lg navbar-light bg-faded justify- content-center">
<div class="container ">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon m-auto"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active mt-5">
<a class="nav-link" href="#">Home <span class="sr-only">(current) </span></a>
</li>
<li class="nav-item mt-5">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item mt-5">
<a class="nav-link" href="#">Gallery</a>
</li>
</ul>
<a class="navbar-brand" href="#"><img src="_images/logo.png" alt="logo"></a>
<ul class="navbar-nav ml-auto">
<li class="nav-item active mt-5">
<a class="nav-link" href="#">Services <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item mt-5">
<a class="nav-link" href="#">Events</a>
</li>
<li class="nav-item mt-5">
<a class="nav-link" href="#">Contact Us</a>
</li>
</ul>
</div>
this is my navigation bootstrap code i used for my navigation
<header>
<div id="carouselExampleIndicators" class=" carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active" style="background-image: url('_images/Slider_1.jpg')">
<div class="carousel-caption d-none d-md-block">
<h3>First Slide</h3>
<p>This is a description for the first slide.</p>
</div>
</div>
<div class="carousel-item" style="background-image: url('_images/Slider_2.jpg')">
<div class="carousel-caption d-none d-md-block">
<h3>Second Slide</h3>
<p>This is a description for the second slide.</p>
</div>
</div>
<div class="carousel-item" style="background-image: url('_images/Slider_3.jpg')">
<div class="carousel-caption d-none d-md-block">
<h3>Third Slide</h3>
<p>This is a description for the third slide.</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>
i am having problem when i view my website on mobile at collapsed navigation stage slider over lap icon of collapsed button which hide that i am new with bootstrap so anyone have idea how to resolve this issue. sorry for bad english
ok here we go,
remove class justify-content-center from nav tag in html this is causing lot of problems, and apply below css this will fix your css issues
.navbar{
min-height: 60px;
}
.navbar .container{
width: 100%;
}
see img1
Related
I'm new using bootstrap and I have a problem implementing a bootstrap menu. It works perfectly until the screen become small and even it adjust the size and shows the 3 line menu, it unfolds behind the next div so I cant see the options. It hides behind the next div which is a carousel .
Thank you in advance.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="row menu">
<div class="collapse navbar-collapse" id="menu">
</div>
</nav>
<header class="themenu">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">MENU</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="#">Main <span class="sr-only"></span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Login</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">
More
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown ">
<a class="dropdown-item" href="#">About us</a>
<a class="dropdown-item" href="#">Story</a>
<a class="dropdown-item" href="#">Others</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Shop</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input id="search" class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-warning my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</header>
</div>
<div class="row justify-content-center thecarousel">
<div class="col-md-7 col-lg-5">
<div id="More" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://via.placeholder.com/500" height="500px" alt="el1" />
<div class="carousel-caption d-none d-md-block">
<h5>Pic1</h5>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/500" height="500px" alt="el2" />
<div class="carousel-caption d-none d-md-block">
<h5>Pic2</h5>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/500" height="500px" alt="el3" />
<div class="carousel-caption d-none d-md-block">
<h5>pic3</h5>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#More" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#More" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<ol class="carousel-indicators">
<li data-target="#More" data-slide-to="0" class="active"></li>
<li data-target="#More" data-slide-to="1"></li>
<li data-target="#More" data-slide-to="2"></li>
</ol>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>
Situation:
At the top I have a navbar and then a carousel.
navbar code
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<a class="navbar-brand order-0 nav-link" href="#">DASA</a>
<div class="collapse navbar-collapse text-right order-lg-0 order-last" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link menWomenKidsHeading" href="#">MEN <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link menWomenKidsHeading" href="#">WOMEN</a>
</li>
<li class="nav-item">
<a class="nav-link menWomenKidsHeading" href="#">KIDS</a>
</li>
</ul>
</div>
<a class="nav-link" href="#"><i class="fas fa-search "></i></a>
<a class="nav-link" href="#"><i class="fas fa-user "></i></a>
<a class="nav-link" href="#"><i class="fas fa-shopping-bag "></i></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="">
<i class="fas fa-bars hamburger"></i>
</span>
</button>
</nav>
Carousel code
<div id="carouselExampleCaptions1" class="carousel slide like" data-ride="carousel like">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions1" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="2"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="3"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
<!-- first item RED ANCHARA -->
<div class="carousel-item active">
<div class="firstBanner" style="background-image: url(images/IMG_2124.JPG);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">
ANCHARA WITH RED BOUTIQUE
</h4>
<button type="button" name="button" class="carousel-button">
SHOP ANCHARA
</button>
</div>
</div>
<!-- second item KIDS -->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/group.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">ANCHARA FOR KIDS</h4>
<button type="button" name="button" class="carousel-button">
SHOP KIDS
</button>
</div>
</div>
<!-- third item MULTI-COLOR ANCHARA-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/anchara1.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">MULTI-COLOR ANCHARA</h4>
<button type="button" name="button" class="carousel-button">
SHOP WOMEN
</button>
</div>
</div>
<!-- fourth item dHOTI-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/hrithik.JPG);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">MARRIAGE DHOTI</h4>
<button type="button" name="button" class="carousel-button">
SHOP DHOTI
</button>
</div>
</div>
<!-- fifth item CUSTOMIZE YOUR CLOTHES-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/20190910_120902.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">STYLE YOUR CLOTHES</h4>
<button type="button" name="button" class="carousel-button">
CUSTOMIZE NOW
</button>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions1" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions1" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I want:
A hidden div above the carousel and when a user hover over the navbar, it should appear above the carousel with colored div.
How can I achieve this using html, css and jq? but feel free to give any suggestion.
Please refer to this code ply code.
https://www.codeply.com/p/Mqp1NSjuMz
From the sounds of it, your carousel is directly after the nav. If this is the case, you can just use an adjacent sibling selector in css, no need for js:
.hidden {
display: none;
background: blue;
color: white;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.carousel {
position: relative;
}
.nav:hover+.carousel .hidden {
display: block;
}
<div class="nav">nav bar</div>
<div class="carousel">
<div class="hidden">hidden div</div>carousel
</div>
You can make this with jQuery. The following has a div this currently hides, but makes it appear as soon the user's mouse hovers over the .navbar.
$(".navbar").hover(
function() {
$("#colored-div").show();
},
function() {
$("#colored-div").hide();
}
);
#colored-div {
width: 100%;
height: 10px;
background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!--**navbar code**-->
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<a class="navbar-brand order-0 nav-link" href="#">DASA</a>
<div class="collapse navbar-collapse text-right order-lg-0 order-last" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link menWomenKidsHeading" href="#">MEN <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link menWomenKidsHeading" href="#">WOMEN</a>
</li>
<li class="nav-item">
<a class="nav-link menWomenKidsHeading" href="#">KIDS</a>
</li>
</ul>
</div>
<a class="nav-link" href="#"><i class="fas fa-search "></i></a>
<a class="nav-link" href="#"><i class="fas fa-user "></i></a>
<a class="nav-link" href="#"><i class="fas fa-shopping-bag "></i></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="">
<i class="fas fa-bars hamburger"></i>
</span>
</button>
</nav>
<!--**colored div**-->
<div id="colored-div"></div>
<!--**Carousel code**-->
<div id="carouselExampleCaptions1" class="carousel slide like" data-ride="carousel like">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions1" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="2"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="3"></li>
<li data-target="#carouselExampleCaptions1" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
<!-- first item RED ANCHARA -->
<div class="carousel-item active">
<div class="firstBanner" style="background-image: url(images/IMG_2124.JPG);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">
ANCHARA WITH RED BOUTIQUE
</h4>
<button type="button" name="button" class="carousel-button">
SHOP ANCHARA
</button>
</div>
</div>
<!-- second item KIDS -->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/group.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">ANCHARA FOR KIDS</h4>
<button type="button" name="button" class="carousel-button">
SHOP KIDS
</button>
</div>
</div>
<!-- third item MULTI-COLOR ANCHARA-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/anchara1.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">MULTI-COLOR ANCHARA</h4>
<button type="button" name="button" class="carousel-button">
SHOP WOMEN
</button>
</div>
</div>
<!-- fourth item dHOTI-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/hrithik.JPG);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">MARRIAGE DHOTI</h4>
<button type="button" name="button" class="carousel-button">
SHOP DHOTI
</button>
</div>
</div>
<!-- fifth item CUSTOMIZE YOUR CLOTHES-->
<div class="carousel-item">
<div class="firstBanner" style="background-image: url(images/20190910_120902.jpg);"></div>
<div class="carousel-caption d-block">
<h4 class="headingClothShortDescription">STYLE YOUR CLOTHES</h4>
<button type="button" name="button" class="carousel-button">
CUSTOMIZE NOW
</button>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions1" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions1" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I'm following this example https://startbootstrap.com/snippets/half-slider/
I'm trying to get image smaller and center
I updated css to reduce size
min-height: 350px;
max-width: 900px;
But it's left bound and sliders icons are stuck to left and right
any pointers?
If i not mistaken what you are asking is make image smaller and center using the example you can do like this at css change this
#carouselExampleIndicators{
margin: auto;
min-height: 350px;
max-width: 900px;
overflow: hidden;
}
.carousel-item {
height: 65vh;
min-height: 350px;
background: no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Start Bootstrap</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>
<header>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active" style="background-image: url('https://source.unsplash.com/RCAhiGJsUUE/1920x1080')">
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">First Slide</h3>
<p class="lead">This is a description for the first slide.</p>
</div>
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url('https://source.unsplash.com/wfh8dDlNFOk/1920x1080')">
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">Second Slide</h3>
<p class="lead">This is a description for the second slide.</p>
</div>
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-image: url('https://source.unsplash.com/O7fzqFEfLlo/1920x1080')">
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">Third Slide</h3>
<p class="lead">This is a description for the third slide.</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>
<!-- Page Content -->
<section class="py-5">
<div class="container">
<h1 class="font-weight-light">Half Page Image Slider</h1>
<p class="lead">The background images for the slider are set directly in the HTML using inline CSS. The images in this snippet are from Unsplash!</p>
</div>
</section>
Hope this helps.
The original example is setting image by using background-image property. If you want to change the width of the image without changing the width of the carousel, just use <img> tag to insert images and style those elements.
.carousel-item {
height: 65vh;
min-height: 350px;
background: no-repeat center center scroll;
}
.carousel-item>img{
max-width:900px;
height:100%;
margin:auto;
display:block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Start Bootstrap</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>
<header>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active">
<img src="https://source.unsplash.com/RCAhiGJsUUE/1920x1080"/>
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">First Slide</h3>
<p class="lead">This is a description for the first slide.</p>
</div>
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item">
<img src="https://source.unsplash.com/wfh8dDlNFOk/1920x1080"/>
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">Second Slide</h3>
<p class="lead">This is a description for the second slide.</p>
</div>
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="">
<img src="https://source.unsplash.com/O7fzqFEfLlo/1920x1080')"/>
<div class="carousel-caption d-none d-md-block">
<h3 class="display-4">Third Slide</h3>
<p class="lead">This is a description for the third slide.</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</header>
<!-- Page Content -->
<section class="py-5">
<div class="container">
<h1 class="font-weight-light">Half Page Image Slider</h1>
<p class="lead">The background images for the slider are set directly in the HTML using inline CSS. The images in this snippet are from Unsplash!</p>
</div>
</section>
This one solved my issue
#carouselExampleIndicators{
margin: auto;
min-height: 550px;
max-width: 900px;
overflow: hidden;
}
.carousel-item{
overflow: hidden; min-height: 550px; max-width: 900px; margin: 0 auto;
}
I wrote a simple Carousel page based on the official documentation.
Reference link:
https://getbootstrap.com/docs/4.4/components/carousel/#with-controls
But the Carousel Control Button is not in the right position.
img1
img2
It seems the Carousel Control Button is in the vertical center of browser but not div element. How should I make it in vertical center of ?
My environment: Debian 10 / Bootstrap 4.4.1(installed by yarn)
here's my code:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<header>
<nav class="navbar navbar-expand-md navbar-light bg-white" style="z-index: 20;">
<div class="container d-flex">
<a class="navbar-brand" href="#">
<img src="http://lorempixel.com/output/nature-q-c-100-50-5.jpg" style="height: 3rem;">
***
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav nav-pills ml-auto">
<li class="nav-item">
<a class="nav-link active" href="#">***<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container-fluid px-0">
<div id="carouselControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="http://lorempixel.com/output/animals-q-c-1280-1024-8.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="http://lorempixel.com/output/business-q-c-1280-1024-7.jpg" class="d-block w-100" alt="...">
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
You have added arrows into .carousel-inner class. Hope now it will help you. if any changes please let me know.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<header>
<nav class="navbar navbar-expand-md navbar-light bg-white" style="z-index: 20;">
<div class="container d-flex">
<a class="navbar-brand" href="#">
<img src="http://lorempixel.com/output/nature-q-c-100-50-5.jpg" style="height: 3rem;"> ***
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav nav-pills ml-auto">
<li class="nav-item">
<a class="nav-link active" href="#">***<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">***</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container-fluid px-0">
<div id="carouselControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="http://lorempixel.com/output/animals-q-c-1280-1024-8.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="http://lorempixel.com/output/business-q-c-1280-1024-7.jpg" class="d-block w-100" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
This question already has answers here:
twitter bootstrap navbar fixed top overlapping site
(19 answers)
Closed 4 years ago.
im trying to create a page with a slider under a navbar but the slider goes behind the navbar.
I searched online and i saw another question with an answer saying to add the top margin to the body and it worked, but when you change slide it starts spasming up and down, and that was "margin-top" fault.
<div>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top">
<img alt="Brand" src="Resources/img/logo.png">
</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">
<a class="nav-link js-scroll-trigger" href="#about">Home</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#services">Informatica</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#contact">Contatti</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div id="sliderImmagini" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#sliderImmagini" data-slide-to="0" class="active"></li>
<li data-target="#sliderImmagini" data-slide-to="1"></li>
<li data-target="#sliderImmagini" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="Resources/img/slider/slide-1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="Resources/img/slider/slide-2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="Resources/img/slider/slide-3.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#sliderImmagini" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Precendente</span>
</a>
<a class="carousel-control-next" href="#sliderImmagini" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Prossimo</span>
</a>
</div>
So now im still stuck with a slider behind the navbar, any help would be apreciated thanks.
If you know the height of the .navbar, you can set a margin-top on the .carousel to force it down the page that amount. This is happening because the .navbar is fixed. This means that you can scroll down the page and have the .navbar stay in place at the top of the page.
Sample:
.navbar{
border:3px solid orange;
}
.carousel{
border: 3px solid green;
margin-top: 70px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#page-top">
<img alt="Brand" src="Resources/img/logo.png">
</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">
<a class="nav-link js-scroll-trigger" href="#about">Home</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#services">Informatica</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#contact">Contatti</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div id="sliderImmagini" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#sliderImmagini" data-slide-to="0" class="active"></li>
<li data-target="#sliderImmagini" data-slide-to="1"></li>
<li data-target="#sliderImmagini" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://i.cdn.turner.com/ads/adspaces/CNN/2018/12/10/840622774_LoveGilda_CNNFilms_1100x619_NewYearsDay.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://cdn.cnn.com/cnnnext/dam/assets/181220163944-01-week-in-photos-1221-super-169.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#sliderImmagini" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Precendente</span>
</a>
<a class="carousel-control-next" href="#sliderImmagini" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Prossimo</span>
</a>
</div>
<p>
lkjsdlkajsdlkjalskdjlakjsd
</p>
<p>
lkjsdlkajsdlkjalskdjlakjsd
</p> <p>
lkjsdlkajsdlkjalskdjlakjsd
</p> <p>
lkjsdlkajsdlkjalskdjlakjsd
</p> <p>
lkjsdlkajsdlkjalskdjlakjsd
</p> <p>
lkjsdlkajsdlkjalskdjlakjsd
</p>