Created
June 25, 2024 16:26
-
-
Save bensonchow123/32df3f8b18c62a3b827466177fb9169a to your computer and use it in GitHub Desktop.
the html code with boostrap 5.3.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="myCarousel" class="carousel slide" data-bs-ride="carousel" data-bs-interval="false"> | |
<!-- Indicators --> | |
<div class="carousel-indicators"> | |
{% for video in project['videos'] %} | |
<button type="button" data-bs-target="#myCarousel" data-bs-slide-to="{{ loop.index0 }}" | |
class="{{'active' if loop.index0 == 0}}" aria-current="true" aria-label="Slide {{ loop.index0 + 1 }}"></button> | |
{% endfor %} | |
{% for photo in project['photos'] %} | |
<button type="button" data-bs-target="#myCarousel" data-bs-slide-to="{{ loop.index0 }}" | |
class="{{'active' if ((loop.index0 == 0) and (not 'videos' in project)) }}" aria-current="true" aria-label="Slide {{ loop.index0 + 1 }}"></button> | |
{% endfor %} | |
</div> | |
<!-- Wrapper for slides --> | |
<div class="carousel-inner"> | |
{% for video in project['videos'] %} | |
<div class="carousel-item {{'active' if loop.index0 == 0}}"> | |
{{ project['videos'][loop.index0] | safe }} | |
</div> | |
{% endfor %} | |
{% for photo in project['photos'] %} | |
<div class="carousel-item {{'active' if ((loop.index0 == 0) and (not 'videos' in project)) }}"> | |
<img src="{{photo}}" alt="project-photo" class="d-block w-100"> | |
</div> | |
{% endfor %} | |
</div> | |
<!-- Left and right controls --> | |
{% if ((project['videos'] | length) + (project['photos'] | length)) > 1 %} | |
<button class="carousel-control-prev" type="button" data-bs-target="#myCarousel" 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="#myCarousel" data-bs-slide="next"> | |
<span class="carousel-control-next-icon" aria-hidden="true"></span> | |
<span class="visually-hidden">Next</span> | |
</button> | |
{% endif %} | |
</div> | |
{% endif %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment