I have a bootstrap carousel in which on each carousel item I am using an image & some text. I want each carousel item to be shown horizontally. But the bootstrap carousel item show me content vertically as shown in the image below.
This is what currently i am getting:
This is what I want each carousel item to look like:
Here is my source code: (Two Carousel items in it)
<div class="g-bg-img-hero" style="background-image: url(dist/images/newPage/svg-bg3.svg);">
<div class="container g-py-50">
<div class="row">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="col-md-6 g-mb-0--md">
<img class="img-fluid u-shadow-v39 g-brd-around g-brd-10 g-brd-white rounded"
src="dist/images/newPage/biggest-expo-on-stem-cells-in-karachi.png" alt="Biggest Stem Cells Conference">
</div>
<div class="col-md-5">
<div class="mb-4">
<h4 class="g-color-black mb-3">$28m Funding Investment for New University of Unify Research</h4>
<p>Food security, epigenetics, media ownership and space weather are among the topics that will be investigated as part of a $28 million funding injection to Unify research from the Australian Research Council (ARC).</p>
</div>
<a class="btn u-shadow-v33 g-color-white g-bg-primary g-bg-black--hover g-font-size-default g-rounded-30 g-px-35 g-py-11" href="#">Read More</a>
</div>
</div>
<div class="carousel-item">
<div class="col-md-6 g-mb-0--md">
<img class="img-fluid u-shadow-v39 g-brd-around g-brd-10 g-brd-white rounded"
src="dist/images/newPage/hira-shaikh.jpg" alt="Nida Yasir Trust on AlKhaleej Clinics">
</div>
<div class="col-md-5">
<div class="mb-4">
<h4 class="g-color-black mb-3">$28m Funding Investment for New University of Unify Research</h4>
<p>Food security, epigenetics, media ownership and space weather are among the topics that will be investigated as part of a $28 million funding injection to Unify research from the Australian Research Council (ARC).</p>
</div>
<a class="btn u-shadow-v33 g-color-white g-bg-primary g-bg-black--hover g-font-size-default g-rounded-30 g-px-35 g-py-11" href="#">Read More</a>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
Well, your structure is incorrect. You need to have the following structure inside each carousel item:
.carousel > .carousel-item > .row > .col-4 + .col-6
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="g-bg-img-hero bg-info">
<div class="container g-py-50">
<div class="row">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="row m-0 p-0">
<div class="col-4 col-md-4 g-mb-0--md">
<img class="img-fluid u-shadow-v39 g-brd-around g-brd-10 g-brd-white rounded" src="https://via.placeholder.com/300x200" alt="Biggest Stem Cells Conference">
</div>
<div class="col-8 col-md-8">
<h4 class="g-color-black mb-3">Item 1 - $28m Funding Investment for New University of Unify Research</h4>
<p>Food security, epigenetics, media ownership and space weather are among the topics that will be investigated as part of a $28 million funding injection to Unify research from the Australian Research Council (ARC).</p>
<a class="btn u-shadow-v33 g-color-white g-bg-primary g-bg-black--hover g-font-size-default g-rounded-30 g-px-35 g-py-11" href="#">Read More</a>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row m-0 p-0">
<div class="col-4 col-md-4 g-mb-0--md">
<img class="img-fluid u-shadow-v39 g-brd-around g-brd-10 g-brd-white rounded" src="https://via.placeholder.com/300x200" alt="Biggest Stem Cells Conference">
</div>
<div class="col-8 col-md-8">
<h4 class="g-color-black mb-3">Item 2 - $28m Funding Investment for New University of Unify Research</h4>
<p>Food security, epigenetics, media ownership and space weather are among the topics that will be investigated as part of a $28 million funding injection to Unify research from the Australian Research Council (ARC).</p>
<a class="btn u-shadow-v33 g-color-white g-bg-primary g-bg-black--hover g-font-size-default g-rounded-30 g-px-35 g-py-11" href="#">Read More</a>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
Related
I am very new to web dev and i am trying to resolve this issue from quite some time, please help me with this,
I have implemented a series of verticle slides each slide contains 10 images and every time i reach bottom i call next images from api call. now i wish to print no. of slide i am presently active on I used below code for it but this way on going to top or below value of slide no. increments and finally becomes constant.
<div class="left">
{{slideno}}
</div>
<div v-for="(images, index) in slides"
:key="index" >{{setslideNumber(index)}}
<div class="container read">
<div
class="col-md-offset-1 col-md-11 col-sm-2 col-xs-12 reader-section"
>
<div
id="carousel-pager"
class="carousel slide "
data-ride="carousel"
data-interval="1000"
>
<div class="carousel-inner vertical">
<div class=" item" style="object-fit: fill;">
<div
v-for="(image, index) in images"
:key="index"
class="section"
style="color:#fff"
>
<img
:src="
image
"
class="img-responsive"
data-target="#carousel-main"
data-slide-to="0"
width:100
/>
</div>
<div v-if="images.length" v-observe-visibility="handleScrolledToBottom"></div>
</div>
</div>
<a
class="left carousel-control"
href="#carousel-pager"
role="button"
data-slide="prev"
>
<span
class="glyphicon glyphicon-chevron-up"
aria-hidden="true"
></span>
<span class="sr-only">Previous</span>
</a>
<a
class="right carousel-control"
href="#carousel-pager"
role="button"
data-slide="next"
>
<span
class="glyphicon glyphicon-chevron-down"
aria-hidden="true"
></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
methods: {
setSlideNumber(index){
this.slideno=index+1;
},
}
what value of sliden0 i am getting: 123....10
what i need the value of slide that is visible,
Im not sure what i am doing wrong but for some reason bootstrap 4 carousel controls is not working if anyone can help I would really appreciate it. Ive been playing around with the code for about an hour so I figure ill get a 2nd opinion to see what is going on.
I looked at the bootstrap docs and I copied and pasted the controls. I looked at the classes and everything looks the same
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous">
<!-- REVIEWS -->
<div id="reviews" class="py-3 bg-green" style="background: #186160;">
<div class="customer-reviews d-block text-center">
<h4> <strong> Customer Reviews </strong></h4>
<div style="color: #ffd400;"> ★ ★ ★ ★ ★</div>
<!-- SLIDER -->
<div class="col-lg-10 offset-lg-1 text-light">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel" >
<div class="carousel-inner" role="listbox">
<!-- SLIDER 1 -->
<div class="carousel-item active text-center pt-4 ">
<blockquote class="blockquote text-center">
<div class="d-flex justify-content-around">
<div>
<p class="mb-0"><i class=" "></i> "I absolutely love this site, probably better than cebook"</p>
<p style="color: #ffd400;">Tomi_Jug****</p>
</div>
<div>
<p class="mb-0"><i class=" "></i> "I love all the users on this site, everyone is fun to talk with."</p>
<p style="color: #ffd400;">Chris****</p>
</div>
</div>
</blockquote>
</div>
<!-- SLIDER 2 -->
<div class="carousel-item text-center pt-4 ">
<blockquote class="blockquote text-center">
<div class="d-flex justify-content-around">
<div>
<p class="mb-0"><i class=" "></i> "I like the freedom it gives me to express, in a safe manner."</p>
<p style="color: #ffd400;">YoruUs**</p>
</div>
<div>
<p class="mb-0"><i class=" "></i> "I love that it's easy to chat with someone. You have a great mobile app. Easy to use."</p>
<p style="color: #ffd400;">HG****</p>
</div>
</div>
</blockquote>
</div>
<!-- SLIDER 3 -->
<div class="carousel-item text-center pt-4 ">
<blockquote class="blockquote text-center">
<div class="d-flex justify-content-around">
<div>
<p class="mb-0"><i class=" "></i> "I like that the site has cool people on it, and I can almost always meet someone new."</p>
<p style="color: #ffd400;">Wet an******</p>
</div>
</div>
</blockquote>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
<!-- SLIDER -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
crossorigin="anonymous"></script>
Ids are different.
Make changes as
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#carouselExampleControls" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
and check
I would like a carousel that fills about half of the window. I've been reading through the documentation https://getbootstrap.com/docs/4.1/components/carousel/ and a following a youtube tutorial for help https://youtu.be/9cKsq14Kfsw?t=3510. My images fill the entire page plus more (when scrolled down) and I can't figure out how to make it smaller other than setting a fixed height in CSS which makes the image look squashed.
Here is my code
html, body {
width: 100%;
height: 100%;
}
.carousel-inner img {
width: 100%;
height: 100%;
}
<!-- Image carousel -->
<div id="slides" class="carousel slide" data-ride="carousel">
<!-- Carousel images -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/home-1.png" />
<div class="carousel-caption">
<h1 class="display-2">Garnet Home Inspections</h1>
</div>
</div>
<div class="carousel-item">
<img src="img/home-2.png" />
<div class="carousel-caption">
<h1 class="display-3">Service Area</h1>
<h3>I travel all over the capital Region</h3>
<button type="button" class="btn btn-outline-light btn-lg">SET UP AN APPOINTMENT</button>
</div>
</div>
<div class="carousel-item">
<img src="img/home-3.png" />
<div class="carousel-caption">
<!-- put content here -->
</div>
</div>
</div>
<!-- Carousel buttons-->
<a class="carousel-control-prev" href="#slides" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span> <!-- Screenreaders only -->
</a>
<a class="carousel-control-next" href="#slides" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span> <!-- Screenreaders only -->
</a>
</div>
Thank you in advance :)
If anyone needs more information/code please let me know.
I have several photo albums (thumbnails, links) on one page. The idea is that when the user clicks on the thumbnail the bootstrap carousel slide show pops up with pictures from this album.
The HTML for one of the albums looks like this (the second one is identical):
<div class="container">
<div class="row">
<!-- Album 1 -->
<div class="col-sm-12 col-md-3 col-lg-3 box">
<span class="spanner"></span>
<div class=thumbnail style="background-image: url(image1.jpg);">
<div class="caption">
<h4>Album 1</h4>
<p class="photo-text">Album 1 description</p>
</div>
</div>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img class="img-responsive" src="image1.jpg" alt="image1">
</div>
<div class="item">
<img class="img-responsive" src="image2.jpg" alt="image2">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The problem is when I press on the album thumbnail both slide shows pop-up. I assume the problem is with "active" but I am not sure how to fix it. Thanks!
Check and make sure both carousels have a different id. Are you using the id to load the carousel?
I was working with carosel in bootstrap and I want background image to be blur and top image to be properly visible. For this I was using two classes in style but as a result both front and back images are coming blur. The fiddle for the same is here https://jsfiddle.net/v37wju8h/6/ . Please increase the screen size to check the problem with the result. Below is the code -
<div class="container">
<div id="carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner"> <!-- Wrapper for slides -->
<div class="item active back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg"/>
<div class="carousel-caption">
<h3>Image1</h3>
</div>
</div>
<div class="item back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg" />
<div class="carousel-caption">
<h3>Image2 </h3>
</div>
</div>
<div class="item back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg" />
<div class="carousel-caption">
<h3>Image 3</h3>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#carousel" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
</div>
You can use opacity
opacity: 0.5
position: relative;