As you can see the logo is displayed above the background-image, but i would like it to be in the center of the background image.
this is my header and the background needs to begin on top of the page and end before the menu. the logo needs to be displayed in the center over the background image.
i have tried a lot but maybe somebody had a similar problem and can help me with this.
this image show the thats its almost working but its behind the background
<html>
<head>
<meta charset="UTF-8">
<link rel='stylesheet' href='//fonts.googleapis.com/css?family=font1|font2|etc' type='text/css'>
<link rel="stylesheet" href="styles.css" type="text/css">
<script src="navbar.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!--bootstrap-->
<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.css">
<script src="styles/js/bootstrap.min.js"></script>
<!--datepicker -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="styles/js/bootstrap.min.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<header>
<div id="theCarousel" class="carousel slide" data-ride="carousel">
<img class="logo" src="fts.png">
<ol class="carousel-indicators">
<li data-target="#theCarousel" data-slide-to="0" class="active">
</li>
<li data-target="#theCarousel" data-slide-to="1">
</li>
<li data-target="#theCarousel" data-slide-to="2">
</li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="slide1">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<div class="slide2">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<div class="slide3">
<div class="carousel-caption">
</div>
</div>
</div></div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"> </span></a>
<a class="right carousel-control" href="#theCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"> </span> </a>
</div>
</header>
<div id="cssmenu" class="align-right">
<ul>
<?php
switch ($_SESSION['isAdmin']) {
case "1":
echo '<li><i class="fa fa-unlock"></i><span>AdminDash</span></li>' ;
break;
case "0":
break;
default:
break;
}
?>
<li><span>DASHBOARD</span><i class="fa fa-home"></i></li>
<li><span><i class="fa fa-ticket"></i> NIEUW TICKET</span></li>
<li><span>ALLE TICKETS</span></li>
<li><span></i> KLANTEN</span></li>
<li class="active"><span><i class="fa fa-sign-out"></i>UITLOGGEN</span></li>
</ul>
</div>
<br><br><br>
</body>
<style>
body {
background-color: #cdcdcd;
width: 100%;
margin: 0 auto;
}
img.logo {
height: 130px;
position: absolute;
margin: auto;
display: block;
top: 80px;
left: 0;
right: 0;
}
header{
width: 100%;
position: relative;
text-align: center;
}
/* Carousel Styling */
.carousel div[class^=slide] {
height: 100px;
width: 100%;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
position: relative;
z-index: -1
}
.slide1{
background-image: url('styles/3.jpg');
}
.slide2{
background-image: url('styles/2.jpg');
}
.slide3{
background-image: url('styles/1.png');
}
</style>
</html>
use position:relative/absolute
img.logo {
height: 90px;
position: absolute;
margin: auto;
display: block;
top: 80px;
left: 0;
right: 0;
}
header {
width: 100%;
position: relative;
text-align: center;
}
/* Carousel Styling */
.carousel div[class^=slide] {
height: 110px;
width: 100%;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
position: relative;
z-index: -1
}
.slide1 {
background-image: url('//placehold.it/500');
}
.slide2 {
background-image: url('styles/2.jpg');
}
.slide3 {
background-image: url('styles/1.png');
}
<header>
<div id="theCarousel" class="carousel slide" data-ride="carousel">
<img class="logo" src="//placehold.it/100/FF0">
<ol class="carousel-indicators">
<li data-target="#theCarousel" data-slide-to="0" class="active">
</li>
<li data-target="#theCarousel" data-slide-to="1">
</li>
<li data-target="#theCarousel" data-slide-to="2">
</li>
</ol>
<div class="carousel-inner">
<div class="item active">
<div class="slide1">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<div class="slide2">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<div class="slide3">
<div class="carousel-caption">
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#theCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"> </span>
</a>
<a class="right carousel-control" href="#theCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"> </span>
</a>
</div>
</header>
Related
I am trying to create carousel responsive image inside the index home page which are being displayed inside the common layout page. But when I reduce the height carousel-item div, full image is not being showed in index html. How can I show the full image as responsive , even if I reduce the height of carousel-item div.?
My code given below
_Layout.cshtml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>#ViewData["Title"] - MyCompany</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
<div class="container-fluid icon-top py-4 px-5">
<div class="row">
</div>
</div>
<header id="header">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">MyCompany</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy">Our Project</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="body-container">
#RenderBody()
</div>
<footer class="border-top footer text-muted">
<div class="container" id>
© 2021 - MyCompany - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/js/all.js"></script>
#await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Index.cshtml
#{
ViewData["Title"] = "Home Page";
}
<section id="home-heading">
<div id="MyCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item carousel-image-1 active">
</div>
<div class="carousel-item carousel-image-2">
</div>
<div class="carousel-item carousel-image-3">
</div>
</div>
<a class="carousel-control-prev" href="#MyCarousel" 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="#MyCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</section>
<!-- INFO SECTION -->
<section id="info" class="py-3>
<div class=" container">
<div class="row">
<div class="col-md-8 align-self-center">
<h3>Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate eveniet blanditiis incidunt iusto
corrupti illum cum laudantium ex sequi amet. ssfsdfs fjjerhehr uiewruhweuiruiewruyhyuewiry iweuyr
ryewiuryiweuy. uieeryewi iuweriwe yb 7weyr7ewy87r7ywe8ry8wer8 we87r y87we78r7we8r
7we87rwe87r87wer8werweuewof
w8ueuwe88ur9we8r </p>
Learn More
</div>
<div class="col-md-4">
<img src="img/laptop.png" alt="" class="img-fluid">
</div>
</div>
</div>
</section>
Site.css
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
#body-container {
/* */
top: 0;
bottom: 0;
right: 0;
left: 0;
}
/* Provide sufficient contrast against white background */
a {
color: #0366d6;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active,
.nav-pills .show>.nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
font-size: 14px;
}
#media (min-width: 768px) {
html {
font-size: 16px;
}
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
}
.footer {
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
/* Vertically center the text there */
}
.icon-top {
background-color: chocolate;
}
.navbar .nav-link {
font-size: 14px !important;
text-align: right !important;
padding-left: 1rem !important;
padding-right: 1rem !important;
}
.navbar .nav-item.active {
border-left: #444 3px solid;
}
.carousel-item {
height: 800px;
}
.carousel-image-1 {
background: url('../img/banner-1.jpeg');
background-size: cover;
}
.carousel-image-2 {
background: url('../img/banner-2.jpeg');
background-size: cover;
}
.carousel-image-3 {
background: url('../img/banner-3.jpeg');
background-size: cover;
}
With Many Thanks
Pol
Add this to your Layout page.
#RenderSection("style", required: false)
Now add your Carousel code to any View page. under#section style{ "your bootstrap carousel code"} so for that, you will successfully show your carousel where you want. also, the carousel fits the full image as responsive.
#section style{
<div id="myCarousel" class="carousel slide" data-ride="carousel" style="margin-top:-15px">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block w-100" style="background-color: gray; height: 550px; width: 100%;" src="~/images/family1.jpeg" alt="Img1" />
<div class="carousel-caption">
<h3>Image 1</h3>
<p>A happy image</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" style="background-color: gray; height: 550px; width: 100%;" src="~/images/family1.jpeg" alt="Img2" />
<div class="carousel-caption">
<h3>Image 2</h3>
<p>A new image</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" style="background-color: gray; height: 550px; width: 100%;" src="~/images/family1.jpeg" alt="Img3" />
<div class="carousel-caption">
<h3>Image 3</h3>
<p>An old image</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
}
I've implemented a bootstrap carousel with thumbnails on my website but the thumbnail size is off, they are way too small.
I fiddled some with the CSS code within the foto_new page. But my knowledge of CSS is not enough to get this working.
Here is my page code:
<head>
<title>Reis Foto"s</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/lo.css">
<link rel="stylesheet" href="css/boots.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<style>
/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 100%;
}
#myCarousel .list-inline {
white-space:nowrap;
overflow-x:auto;
}
#myCarousel .carousel-indicators {
position: static;
left: initial;
width: initial;
margin-left: initial;
}
#myCarousel .carousel-indicators > li {
<!--width: initial;-->
<!--height: initial;-->
width: 200px;
height: 50px;
text-indent: initial;
}
<!--#myCarousel .carousel-indicators li img {-->
<!--display: block;-->
<!--opacity: 0.5;-->
<!--}-->
#myCarousel .carousel-indicators li.active img {
opacity: 1;
}
#myCarousel .carousel-indicators li:hover img {
opacity: 0.75;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<!--Ik gebruik hieronder alleen het middiv omdat dat de enige info is die ik wil vervangen-->
<div class="col-md-12" id="middiv" style="background-color: rgba(255, 255, 255, 0.1)">
<div id="myCarousel" class="carousel slide" data-ride="carousel" align="center">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="/fotos/auto.jpg" alt="Los Angeles" style="width:80%;">
</div>
<div class="carousel-item">
<img src="/fotos/robot.jpg" alt="Chicago" style="width:80%;">
</div>
<div class="carousel-item">
<img src="/fotos/vrachtwagen.jpg" alt="New york" style="width:80%;">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myCarousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
<!-- Indicators -->
<ol class="carousel-indicators list-inline">
<li class="list-inline-item active">
<a id="carousel-selector-0" class="selected" data-slide-to="0" data-target="#myCarousel">
<img src="/fotos/auto.jpg" class="img-fluid">
</a>
</li>
<li class="list-inline-item">
<a id="carousel-selector-1" data-slide-to="1" data-target="#myCarousel">
<img src="/fotos/robot.jpg" class="img-fluid">
</a>
</li>
<li class="list-inline-item">
<a id="carousel-selector-2" data-slide-to="2" data-target="#myCarousel">
<img src="/fotos/vrachtwagen.jpg" class="img-fluid">
</a>
</li>
</ol>
</div>
</div>
</div>
</div>
</body>
</html>
I expect that the thumbnails are a bigger size.
Not sure how this will play with the rest of your CSS.
/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 100%;
}
#myCarousel .carousel-indicators {
position: static;
margin-top:20px;
}
#myCarousel .carousel-indicators > li {
width:100px;
}
#myCarousel .carousel-indicators li img {
display: block;
opacity: 0.5;
}
#myCarousel .carousel-indicators li.active img {
opacity: 1;
}
#myCarousel .carousel-indicators li:hover img {
opacity: 0.75;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha256-YLGeXaapI0/5IgZopewRJcFXomhRMlYYjugPLSyNjTY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" integrity="sha256-UzFD2WYH2U1dQpKDjjZK72VtPeWP50NoJjd26rnAdUI=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.js" integrity="sha256-BTlTdQO9/fascB1drekrDVkaKd9PkwBymMlHOiG+qLI=" crossorigin="anonymous"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.15.0/esm/popper.min.js" integrity="sha256-3Iu0zFU6cPS92RSC3Pe4DBwjIV/9XKyzYTqKZzly6A8=" crossorigin="anonymous"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha256-CjSoeELFOcH0/uxWu6mC/Vlrc1AARqbm/jiiImDGV3s=" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<!--Ik gebruik hieronder alleen het middiv omdat dat de enige info is die ik wil vervangen-->
<div class="col-md-12" id="middiv" style="background-color: rgba(255, 255, 255, 0.1)">
<div id="myCarousel" class="carousel slide" data-ride="carousel" align="center">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://dummyimage.com/600x400/000/fff" alt="Los Angeles" style="width:80%;">
</div>
<div class="carousel-item">
<img src="https://dummyimage.com/600x400/000/fff" alt="Chicago" style="width:80%;">
</div>
<div class="carousel-item">
<img src="https://dummyimage.com/600x400/000/fff" alt="New york" style="width:80%;">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myCarousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
<!-- Indicators -->
<ol class="carousel-indicators list-inline">
<li class="list-inline-item active">
<a id="carousel-selector-0" class="selected" data-slide-to="0" data-target="#myCarousel">
<img src="https://dummyimage.com/600x400/000/fff" class="img-fluid">
</a>
</li>
<li class="list-inline-item">
<a id="carousel-selector-1" data-slide-to="1" data-target="#myCarousel">
<img src="https://dummyimage.com/600x400/000/fff" class="img-fluid">
</a>
</li>
<li class="list-inline-item">
<a id="carousel-selector-2" data-slide-to="2" data-target="#myCarousel">
<img src="https://dummyimage.com/600x400/000/fff" class="img-fluid">
</a>
</li>
</ol>
</div>
</div>
</div>
</div>
It does look like it is response, and you can change the thumbnail sizes with the:
#myCarousel .carousel-indicators > li {
width:100px;
}
There is some issues with the popper.js loading, which is why it is commented out.
There is a Fiddle: Demo
for some reason on both sides of my screen on the header I have white space. I have tried to close the margin and padding but it doesn't work. As well, how do you center links on a bootstrap navbar. I tried the bootstrap commands and custom but it won't center.
<!DOCTYPE html>
<html>
<head>
<!-- JavaScript compile -->
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<title>VE Website</title>
<meta charset="UTF-8">
<meta name="author" content="Joaquin Frommer">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
html,body{
height: auto;
margin:0;
padding:0;
}
.carousel,.item,.active{
height: auto;}
.carousel-inner{
height: auto;}
.img{
height:auto; width:100%}
.navbar-default {
position: absolute;
left: 0;
right: 0;
width: 100%;
background-color: #e5b984;
z-index: 99999;
}
.navbar {
min-height: 20px;
}
.navbar-brand {
height: 20px; line-height: 20px;
}
.navbar-default .navbar-nav > li > a {
color: #703d41;
}
.nav-item:hover{
background-color: #fff0bb;
color: #703d41;
}
.nav-item{
font-size: 14px;
padding-left: 85px;
padding-right: 85px;
}
.navbar-nav li a {
line-height: 20px;
}
.navbar-header a {
line-height:20px;
}
.carousel{
position: relative;
}
header{
background-image: url(skyline.jpg);
left:0;
right:0;
width:100%;
}
h1{
margin:0;
padding:0;
right:0;
left:0;
width: 100%;
}
</style>
<script>
$('.carousel').carousel({
interval: 10000,
pause: "false",
wrap: "true"
});
var $item = $('.carousel .item');
var $wHeight = $(window).height();
$item.height($wHeight);
$item.addClass('full-screen');
$('.carousel img').each(function() {
var $src = $(this).attr('src');
var $color = $(this).attr('data-color');
$(this).parent().css({
'background-image' : 'url(' + $src + ')',
'background-color' : $color
});
$(this).remove();
});
$(window).on('resize', function (){
$wHeight = $(window).height();
$item.height($wHeight);
});
$item.eq(0).addClass('active');
});
</script>
<div class="container-fluid body">
<header>
<center>
<h1 class="img-responsive"><img style="margin: 0; padding: 0; background-position: center center;" src="logoNomad.png" height="97" width="97"></h1>
</center>
</header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="fixedstuff">
<ul class="nav navbar-nav">
<li class="nav-item"><a class="nav-link" href="#">HOME</a></li>
<li class="nav-item"><a class="nav-link" href="#">ABOUT</a></li>
<li class="nav-item"><a class="nav-link"href="#">CHARITY</a></li>
<li class="nav-item"><a class="nav-link"href="#">RESERVE</a></li>
<li class="nav-item"><a class="nav-link"href="#">ACOUNTS</a></li>
</ul>
</div>
</div>
</div>
</nav>
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0" class="active"></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
<li data-target="#mycarousel" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="image2.jpg" data-color="lightblue" alt="First Image" class="img-responsive">
<div class="carousel-caption">
<h3>First Image</h3>
</div>
</div>
<div class="item">
<img src="image1.jpg" data-color="firebrick" alt="Second Image" class="img-responsive">
<div class="carousel-caption">
<h3>Second Image</h3>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1024x700" data-color="firebrick" alt="Second Image" class="img-responsive">
<div class="carousel-caption">
<h3>Third image Image</h3>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1024x700" data-color="firebrick" alt="Second Image" class="img-responsive">
<div class="carousel-caption">
<h3>Fourth Image</h3>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1024x700" data-color="firebrick" alt="Second Image" class="img-responsive">
<div class="carousel-caption">
<h3>Fifth Image</h3>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#mycarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#mycarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</html>here
Its because container-fluid class adds padding of 15px on both sides.
just create a nopadding class and add besides the container-fluid class.
.nopadding{
padding-left:0;
padding:right:0;
}
<div class="container-fluid nopadding">...</div>
as for centering the links add bootstrap's "text-center" class to your links, make sure you use media queries else they will centered for all devices
<li class="nav-item"><a class="nav-link text-center" href="#">HOME</a></li>
I trying add "tooltip bootstrap" to my web site and has fail. It's doesn't work for me, but early i used it and all was fine. Maybe my css styles wrapping some bootstrap styles. Can someone help?
my html
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
#media (min-width: 1024px) and (max-width: 2560px) {
.navbar-custom-header,
.navbar-custom-footer {
background-color: bisque;
margin-bottom: 0px;
width: 100%;
height: auto;
text-align: center;
display: block;
overflow: hidden;
}
.navbar-nav {
float: none;
list-style: none;
display: inline-block;
vertical-align: middle;
margin: 0;
padding: 0;
>li {
display: inline-block;
}
}
.navbar-custom-header .navbar-nav li a:hover {
color: darkgreen;
text-decoration: none;
background-color: bisque;
}
.navbar-custom-footer .navbar-nav li a:hover {
color: darkgreen;
text-decoration: none;
background-color: bisque;
}
.navbar-custom-header .navbar-nav li .nav-ref {
color: white;
font-size: 40px;
font-family: Allegretto Script One;
}
.navi_images {
width: 120px;
height: 60px;
}
#font-face {
font-family: Allegretto Script One;
src: url(fonts/AllegrettoScriptOne.ttf);
}
.footer_images {
width: 280px;
height: 60px;
}
.navbar-custom-header .navbar-nav li a {
padding: 0px 0px 0px 0px;
line-height: 60px;
}
.navbar-custom-footer .navbar-nav li a {
padding: 0px 0px 0px 0px;
line-height: 62px;
}
.navbar-custom-footer .navbar-nav li a .footer_logos {
width: 35px;
height: 35px;
}
.tooltip > .tooltip-inner {
font-family: Allegretto Script One;
font-size: 26px;
}
}
<!DOCTYPE html>
<html lang="en">
<title>Главная страница</title>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta charset="utf-8">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page
via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/
html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/
respond.min.js"></script>
<![endif]-->
<!-- Bootstrap source-->
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<!-- Own style-->
<link rel="stylesheet" href="index.css">
</head>
<body>
<!-- Header -->
<nav class="navbar navbar-custom-header" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>Main
</li>
<li>
<img class="navi_images" src="images/rose+garland.png" />
</li>
<li>Portfolio
</li>
<li>
<img class="navi_images" src="images/rose+garland.png" />
</li>
<li>Contacts
</li>
<li>
<img class="navi_images" src="images/rose+garland.png" />
</li>
<li>Reviews
</li>
</ul>
</div>
</nav>
<!-- Main content-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/021.JPG" alt="...">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="images/FXUw2IOSk6I.jpg" alt="...">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="images/kLaceXVf9Iw.jpg" alt="...">
<div class="carousel-caption">
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- Footer -->
<nav class="navbar navbar-custom-footer" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>
<img src="images/Originals/example.png" class="footer_images">
</li>
<li>
<a href="#" data-toggle="tooltip" data-placement="top" title="Instagram">
<img src="images/insta.png" class="footer_logos">
</a>
</li>
<li>
<a href="https://vk.com/pricheskiotkylikludmilu" data-toggle="tooltip" data-placement="top" title="Vkontakte">
<img src="images/vk.png" class="footer_logos">
</a>
</li>
<li>
<img src="images/Originals/example.png" class="footer_images">
</li>
</ul>
</div>
</nav>
<script src="bootstrap/jquery/jquery-2.2.2.min.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
your code is working . try adding bootstrap from external resources . see snippet below :
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
#media (min-width: 1024px) and (max-width: 2560px) {
.navbar-custom-header, .navbar-custom-footer {
background-color: bisque;
margin-bottom: 0px;
width: 100%;
height: auto;
text-align: center;
display: block;
overflow: hidden;
}
.navbar-nav {
float: none;
list-style: none;
display: inline-block;
vertical-align: middle;
margin: 0;
padding: 0;
>li {
display: inline-block;
}
}
.navbar-custom-header .navbar-nav li a:hover {
color: darkgreen;
text-decoration: none;
background-color: bisque;
}
.navbar-custom-footer .navbar-nav li a:hover {
color: darkgreen;
text-decoration: none;
background-color: bisque;
}
.navbar-custom-header .navbar-nav li .nav-ref {
color: white;
font-size: 40px;
font-family: Allegretto Script One;
}
.navi_images {
width: 120px;
height: 60px;
}
#font-face {
font-family: Allegretto Script One;
src: url(fonts/AllegrettoScriptOne.ttf);
}
.footer_images {
width: 280px;
height: 60px;
}
.navbar-custom-header .navbar-nav li a {
padding: 0px 0px 0px 0px;
line-height: 60px;
}
.navbar-custom-footer .navbar-nav li a {
padding: 0px 0px 0px 0px;
line-height: 62px;
}
.navbar-custom-footer .navbar-nav li a .footer_logos {
width: 35px;
height: 35px;
}
.tooltip > .tooltip-inner {
font-family: Allegretto Script One;
font-size: 26px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<nav class="navbar navbar-custom-header" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li>Main</li>
<li><img class="navi_images" src="images/rose+garland.png"/></li>
<li>Portfolio</li>
<li><img class="navi_images" src="images/rose+garland.png"/></li>
<li>Contacts</li>
<li><img class="navi_images" src="images/rose+garland.png"/></li>
<li>Reviews</li>
</ul>
</div>
</nav>
<!-- Main content-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/021.JPG" alt="...">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="images/FXUw2IOSk6I.jpg" alt="...">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="images/kLaceXVf9Iw.jpg" alt="...">
<div class="carousel-caption">
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- Footer -->
<nav class="navbar navbar-custom-footer" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><img src="images/Originals/example.png" class="footer_images"></li>
<li><img src="images/insta.png" class="footer_logos"></li>
<li><img src="images/vk.png" class="footer_logos"></li>
<li><img src="images/Originals/example.png" class="footer_images"></li>
</ul>
</div>
</nav>
I have a bootstrap carousel with a fixed height. Here is the CSS:
.carousel-custom .carousel-outer {
position: relative;
}
#media(min-width: 992px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:500px;
line-height:300px;
}
}
}
}
#media(max-width: 991px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:300px;
line-height:300px;
text-align:center;
}
}
}
}
And here is my markup:
<div id="carousel-custom-1188" class="carousel slide carousel-custom" data-ride="carousel">
<div class="carousel-outer">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459261752/w8edcuvz1yl3uc4g4o34.jpg" alt="Jinallzupvfazqqr67nd">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459175684/w4ueot8o49dh2fyulv0x.jpg" alt="K1yov5hpur8mgsb9r15p">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459178926/fwlmuroj2wlz7czrsha0.jpg" alt="Lqfandhmutdkppjrl932">
<div class="carousel-caption"></div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-custom-1188" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-custom-1188" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!-- Indicators -->
<ol class="carousel-indicators mCustomScrollbar">
<li data-target="#carousel-custom-1188" data-slide-to="0" class="active">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268139/jinallzupvfazqqr67nd.png" alt="Jinallzupvfazqqr67nd">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="1" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268146/k1yov5hpur8mgsb9r15p.png" alt="K1yov5hpur8mgsb9r15p">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="2" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268157/lqfandhmutdkppjrl932.png" alt="Lqfandhmutdkppjrl932">
</li>
</ol>
</div>
</div>
The issue is that I have images that are very wide, others very narrow and high, and others with a good ration height/width in the same carousel.
I'd like to have the wide images centered vertically (with a width of a 100%), high images centered horizontally (with a height of 100%) and "normal" images (with a decent ratio height/width) filling all the carousel.
Here is what I'm trying to do (first image is an example with a very wide image, second image with a very high one, and last one has a "decent" ratio).
How could I achieve this ? I've tried Make Bootstrap's Carousel both center AND responsive? and other tricks found on Google but none did this.
Since the .item elements are relative positioned you could just position the img elements absolutely. Giving the .item elements a fixed height, will help to vertically and horizontally align the images inside.
I'm sure there are lots of different ways to do this, here is one example. Hope it helps.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
body {
background-color: black;
}
.carousel-inner > .item {
height: 100vh;
}
.carousel-inner > .item > img {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
max-height: 800px;
width: auto;
}
.carousel-control.left,
.carousel-control.right {
background-image: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- inner -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/1200x600/2c3e50/000" alt="">
</div>
<div class="item">
<img src="http://placehold.it/600x1200/d35400/000" alt="">
</div>
<div class="item">
<img src="http://placehold.it/600x600/c0392b/000" alt="">
</div>
</div>
<!-- controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Alright, I've been fiddling around for a while now. Ended up with the result below. Hope it helps and answers your question (at least for a small part).
<head>
<title>Bootstrap Carousel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
html,
body {
height: 100%;
}
.carousel,
.item,
.active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
/* Background images are set within the HTML using inline CSS, not here */
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
footer {
margin: 50px 0;
}
.tester {
height: 100%;
}
</style>
</head>
<body>
<div class="tester">
<!-- Full Page Image Background Carousel Header -->
<header id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for Slides -->
<div class="carousel-inner">
<div class="item active">
<!-- Set the first background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://res.cloudinary.com/dltbqhact/image/upload/v1459268139/jinallzupvfazqqr67nd.png');"></div>
<div class="carousel-caption">
<h2>Caption 1</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://res.cloudinary.com/dltbqhact/image/upload/v1459268146/k1yov5hpur8mgsb9r15p.png');"></div>
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://res.cloudinary.com/dltbqhact/image/upload/v1459268157/lqfandhmutdkppjrl932.png');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>
</header>
<script>
$('.carousel').carousel({
interval: 5000 //changes the speed
})
</script>
</div>
</body>
Again, hope it helps!
simply use image on absolute if your slider height is fixed
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="middle">
<img src="http://placehold.it/1920x500">
</div>
</div>
<div class="item">
<div class="middle">
<img src="http://placehold.it/1920x300">
</div>
</div>
<div class="item">
<div class="middle">
<img src="http://placehold.it/600x900">
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
css
.carousel {
width: 500px; /*test width*/
height: 300px; /*what ever height */
}
.middle {
position: relative;
height: 300px; /*what ever height */
}
.middle img {
max-width: 100%;
max-height: 100%; /*what ever height */
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
see fiddle
If you try to achieve this in bootstrap carousel, you will end up with black bars in top and bottom...I was stuck with similar problem and ended up using "flickity" js library..it works lot better than tryig to achieve this on something not meant for this....