Boostrap 5 Carousel alignment and image resize - html

Iam trying to bring the carousel to my liking but have some issues. I have set my whole page to be center aligned. When iam trying to resize my carousel images it isnt at the center anymore.
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button
type="button"
data-bs-target="#carouselExampleIndicators"
data-bs-slide-to="0"
class="active"
aria-current="true"
aria-label="Slide 1"
></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="3" aria-label="Slide 3"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="4" aria-label="Slide 4"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="5" aria-label="Slide 5"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/Full Stack Developer.png" class="d-block w-100" alt="full-stack-developer-logo" />
</div>
<div class="carousel-item">
<img src="images/Microsoft Office.png" class="d-block w-100" alt="Microsoft-Office-Suite-logo" />
</div>
<div class="carousel-item">
<img src="images/Adobe Suite.png" class="d-block w-100" alt="Adobe-Suite-logo" />
</div>
<div class="carousel-item">
<img src="images/3dsmaxsuite.png" class="d-block w-100" alt="3dsmax-suite-logo" />
</div>
<div class="carousel-item">
<img src="images/Pixologic Zbrush.png" class="d-block w-100" alt="Pixologic-zbrush-logo" />
</div>
<div class="carousel-item">
<img src="images/Unreal Engine Suite.png" class="d-block w-100" alt="unreal-engine-logo" />
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>

Related

Why Bootstrap 5 Carousel Control Buttons Not Working?

I made a carousel, when I touch these buttons, I want it to go, but it doesn't. How can I do this?
Code:
<div class="container mt-4">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1">1</button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2">2</button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3">3</button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="Third slide">
</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>
</div>
Here's one that's working copied from the official documentation.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<div id="carouselExampleIndicators" class="carousel slide">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://fastly.picsum.photos/id/870/800/400.jpg?hmac=RVmKPEQDqKbI8SLlLbkfaMuxiJVQrPuMoyv7vuxPbL8" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://fastly.picsum.photos/id/494/800/400.jpg?hmac=aPwfyKjkUw_ivDNPavHejXC1zg_pSk3LgmPToXqbKOA" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://fastly.picsum.photos/id/243/800/400.jpg?hmac=IEsjm30yORWR_y11K0bSLyasctvraSJ_sgNgSNNqQk8" class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>

how to center img inide img slider from bootstrap Carousel?

Im having problem centering the img to its place using bootstrap 5 img slider carousel:
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="../images/1.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item">
<img src="../images/2.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item">
<img src="../images/3.jpg" class="w-25" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
I took the code from: bootstrap Carousel
Here, You have set 25% with of carousal item image. So, You will need to add text align center for carousal item. You can use simple text-center bootstrap class for that.
Your <div class="carousel-inner"> code should be as below:
<div class="carousel-inner">
<div class="carousel-item text-center active">
<img src="../images/1.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item text-center">
<img src="../images/2.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item text-center">
<img src="../images/3.jpg" class="w-25" alt="...">
</div>
</div>
select the div of each image with their class in your CSS and write text-align:center; this way it gets centered. (Simply use the code I sent)
.carousel-item{
text-align: center;
}

Bootstrap Carousel slide not working and format too

I followed the professor's instructions correctly, however this is the result. Someone can help me please?
My example
This is how the professor has done:
Professor's carousel
<div class="container"><!--Start row contents-->
<div class="row row-content">
<div class="col">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/uthappizza.png" class="d-block img-fluid" alt="uthappizza">
</div>
<div class="carousel-item">
<img src="img/buffet.png" class="d-block img-fluid" alt="buffet">
</div>
<div class="carousel-item">
<img src="img/alberto.png" class="d-block img-fluid" alt="alberto">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>
I ran your code and it's working. I guess you mean why in your professor's version you can see some pictures on the carousel, but not in your version. You can easily do that by adding captions to your slides with the .carousel-caption element within any .carousel-item. You can read more about it on the following page:
https://getbootstrap.com/docs/5.1/components/carousel/
<div class="container">
<!--Start row contents-->
<div class="row row-content">
<div class="col">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0"
class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/uthappizza.png" class="d-block img-fluid" alt="uthappizza">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="img/buffet.png" class="d-block img-fluid" alt="buffet">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="img/alberto.png" class="d-block img-fluid" alt="alberto">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators"
data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>

Need help putting button on top of carousel img

My image in the carousel is currently covering my button. Any help on getting the button to sit on top of the image would be greatly appreciated.
carousel.component.html
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="assets/myimg8.jpg" class="d-block w-100 myImg" alt="...">
<button type="button" class="btn btn-dark myButton">Dark</button>
</div>
<div class="carousel-item">
<img src="assets/myimg.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="assets/myimg6.jpg" class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
carouel.component.scss
.carousel-item{
position: relative;
}
.carousel-item button {
position: absolute;
}
Actually, your problem is not with the z-index property.
Replace
position: absolute;
with
position: relative;
and you'll see it again.
Now, once the relative value has been used, you can use one of the following properties : top, left, bottom and right.
If you want your button to sit on top of the image, a solution could be this :
.carousel-inner button {
position: relative;
top: -7em;
}

Bootstrap carousel wont show images when i run it in django but they load perfectly fine when i use them in a normal HTML file

I used this bootstrap code to insert a carousel in my django website homepage , but the local images just wont load , how ever if i use images from web apis like unsplash they load perfectly fine , or if i use this code in a normal html file they load just fine , it just wont run in django
<body>
<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img1.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="img2.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="img3.jpg" class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.3/dist/umd/popper.min.js"
integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/js/bootstrap.min.js"
integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/"
crossorigin="anonymous"></script>
</body>
</html>
Django treat static files i.e. images ,css, js not like normal html. please follow https://docs.djangoproject.com/en/3.2/howto/static-files/