I copied a Bootstrap carousel code to understand how it works but the code isn't giving me the desired result. The slides aren't moving.The first slide is just stagnant. Please what do you reccommend I do? Here are the html and css codes. I also included a screenshot of it for more clarification.
html
<div class="carousel-inner">
<div class="carousel-item active" style="background-color: red;">
<img src="..." class="d-block w-100" alt="First slide">
</div>
<div class="carousel-item" style="background-color: yellow;">
<img src="..." class="d-block w-100" alt="Second slide">
</div>
<div class="carousel-item" style="background-color: purple;">
<img src="..." class="d-block w-100" alt="Third slide">
</div>
</div>
</div>
css
.carousel-item {
height: 500px;
}
You need to have the proper parent with the appropriate id and data-ride that correlates with Bootstrap. Then you need to add the relative JS and CSS for Bootstrap 4.
.carousel-item {
height: 500px;
}
<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 id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" style="background-color: red;">
<img src="..." class="d-block w-100" alt="First slide">
</div>
<div class="carousel-item" style="background-color: yellow;">
<img src="..." class="d-block w-100" alt="Second slide">
</div>
<div class="carousel-item" style="background-color: purple;">
<img src="..." class="d-block w-100" alt="Third slide">
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></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>
Add this code inside "head" tag of your .html file.
Why do you need to add this? The answer is whenever you are using a 3rd party library either you need to install it in your project or use its CDN to make it work.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
Related
I want a carousel to occupy half the page and to be aligned to the right while the text should be aligned to the left of the box.
I am using bootstrap. Here is my html:
.main{
display: flex;
align-items: center;
}
#events{
display: flex;
justify-content: space-evenly ;
}
.card{
border-radius: 5%;
}
#myNavbar{
align-items: center;
}
.impact{
margin: 10px;
}
<div class="main">
<div class="impact">
<span>
IMPACTING THE BANGLADESHI COMMUNITY IN OMAN!
</span>
</div>
<div id="carousel" class="carousel slide impact" data-bs-ride="carousel">
<div class="carousel-inner impact" style="height: 500px;">
<div class="carousel-item active">
<img src="{% static 'social_club/web1.jpg' %}" class="d-block w-100 h-100" alt="">
</div>
<div class="carousel-item">
<img src="{% static 'social_club/web2.jpg' %}" class="d-block w-100" alt="">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="..."> </div>
</div>
</div>
</div>
Could someone please tell me how I can make this possible? I have searched quite a lot about making the carousel only occupy half the page, but without results.
If you are using Bootstrap 4 or Bootstrap 5, you have no need to add custom CSS. You can achieve this by using Bootstrap classes. In the following code snippet, I am using Bootstrap 5.
Here is the complete implementation of your code. Please make sure to add closing tags correctly.
Note: Don't add static height to any element for an accurate vertically center alignment effect.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="main d-flex align-items-center">
<div class="impact w-50">
<span>
IMPACTING THE BANGLADESHI COMMUNITY IN OMAN!
</span>
</div>
<div id="carousel" class="carousel slide impact w-50" data-bs-ride="carousel">
<div class="carousel-inner impact">
<div class="carousel-item active">
<img src="https://blog.getbootstrap.com/assets/img/2020/06/v5-new-logo.png" class="d-block w-100 h-100" alt="">
</div>
<div class="carousel-item">
<img src="https://www.winklix.com/blog/wp-content/uploads/2021/01/f1ce6a0af5cb.jpg.png" class="d-block w-100" alt="">
</div>
<div class="carousel-item">
<img src="https://htmlburger.com/blog/wp-content/uploads/2021/02/lets-talk-about-bootstrap.png" class="d-block w-100" alt="...">
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
I was trying to make a carousel for my website using Bootstrap, but the carousel just gives me this icon:
My Google dev tools did not give me errors, the same can be said for Pycharm; no errors. Here is my code:
<div class="container">
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\one.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\two.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\three.jpg" class="d-block w-100" alt="...">
</div>
</div>
</div>
</div>
ok, i found out the problem, for some reson, my computer only accepted gif links, now it is working properly
I have no idea what i am doing wrong. The slide i have here works just great on edge, but not on chrome. What am i missing?
And on the side note; image-responsive clsas for images makes them responsive on chrome but not on edge. I have a feeling that these issues are coraleted. Can they?
Edit: Slide animation is missing in firefox too!
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<div class="slide">
<div class="container">
<div class="row">
<div class="kampanyainfo px-0">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://images.unsplash.com/photo-1517994112540-009c47ea476b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://images.unsplash.com/photo-1494905998402-395d579af36f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://images.unsplash.com/photo-1503736334956-4c8f8e92946d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9" alt="Third slide">
</div>
</div>
<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>
</div>
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
I would like to do a carousel in bootstrap which is split into 187x300 slides but the slides to stay some sort of next each other with a little space between them.
Also, I have resized the carousel to the size of the slide but the only visible arrow is the left one and it's on the slide itself.
I would like it to be outside of it of some sort like to the left but outside of the slide (same for the right side).
I will attach an image as for example.
Also (I know I am repeating myself), if it's not too heavy for this question I would like it to do it like some sort of a Netflix carousel so on hover of the slide the image becomes a tiny bit bigger and it has a black overlay with text over the overlay. Thank you.
Code :
index.html
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Na merge</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="css/test.css">
</head>
<body>
<div class="carousel slide carousel-fade" data-ride="carousel">
<!--Slides-->
<div class="carousel-inner" role="listbox">
<!--First slide-->
<div class="carousel-item active">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="First slide">
</div>
<!--/First slide-->
<!--Second slide-->
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Second slide">
</div>
<!--/Second slide-->
<!--Third slide-->
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Third slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Third slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Fourth slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Fifth slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/187x300"
alt="Sixth slide">
</div>
<!--/Third slide-->
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#fullCarousel" 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="#fullCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>
<!--/.Carousel Wrapper-->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
style.css
.carousel-item{
height: 300px;
width: 187px;
}
.carousel-item img{
height: 300px;
width: 187px;
}
Please remove this style :
.carousel-item{
height: 300px;
width: 187px;
}
Then add your items into one item like this :
<div class="carousel-item">
<div class="row">
<div class="col-sm">
<img src"...">
</div>
<div class="col-sm">
<img src="...">
</div>
<div class="col-sm">
<img src="...">
</div>
<div class="col-sm">
<img src="...">
</div>
</div>
</div>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/images/1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/3.jpg" alt="Third slide">
</div>
</div>
</div>
This is my code. This code just displays images one by one. The slide is not working.
You should add the references on your html like below code snippet.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/images/1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/3.jpg" alt="Third slide">
</div>
</div>
</div>