STORIES INSTAGRAM
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Banner de Stories</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f3f3f3;
}
.stories-banner {
width: 300px;
height: 540px;
position: relative;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}
.story {
width: 100%;
height: 100%;
position: absolute;
opacity: 0;
transition: opacity 1s ease;
}
.story.active {
opacity: 1;
}
.story img {
width: 100%;
height: 100%;
object-fit: cover;
}
.story-indicators {
display: flex;
justify-content: center;
margin-top: 20px;
}
.story-indicators span {
display: inline-block;
width: 12px;
height: 12px;
margin: 0 5px;
background-color: #ddd;
border-radius: 50%;
cursor: pointer;
transition: background-color 0.3s ease;
}
.story-indicators span.active {
background-color: #ff2d55;
}
</style>
</head>
<body>
<div class="stories-banner">
<div class="story active" id="story1">
<img src="https://nuti.furg.br/images/3.jpg" alt="Story 1">
</div>
<div class="story" id="story2">
<img src="https://nuti.furg.br/images/30-09-2023-nuti-1-furg.jpeg" alt="Story 2">
</div>
<div class="story" id="story3">
<img src="https://nuti.furg.br/images/e1.jpg" alt="Story 3">
</div>
</div>
<div class="story-indicators">
<span data-target="story1" class="active"></span>
<span data-target="story2"></span>
<span data-target="story3"></span>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const stories = document.querySelectorAll('.story');
const indicators = document.querySelectorAll('.story-indicators span');
let currentStory = 0;
function showStory(index) {
stories.forEach((story, i) => {
story.classList.remove('active');
indicators[i].classList.remove('active');
});
stories[index].classList.add('active');
indicators[index].classList.add('active');
}
function nextStory() {
currentStory = (currentStory + 1) % stories.length;
showStory(currentStory);
}
setInterval(nextStory, 3000); // Muda o story a cada 3 segundos
indicators.forEach((indicator, i) => {
indicator.addEventListener('click', () => {
currentStory = i;
showStory(i);
});
});
});
</script>
</body>
</html>