Skip to content

cssMemeSlider #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added cssMemeSlider/img/img01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cssMemeSlider/img/img02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cssMemeSlider/img/img03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cssMemeSlider/img/img04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions cssMemeSlider/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--==================== CSS ====================-->
<link rel="stylesheet" href="./style.css">

<title>CSS Meme Slider</title>
</head>
<body>
<section class="container">
<div class="slider-container">
<div class="slider-images">
<img id="imgOne" class="img img-active" src="./img/img01.jpg" alt="Image one">
<img id="imgTwo" class="img" src="./img/img02.jpg" alt="Image two">
<img id="imgThree" class="img" src="./img/img03.jpg" alt="Image three">
<img id="imgFour" class="img" src="./img/img04.png" alt="Image Four">
</div>

<div class="slider-card">
<div class="slider-text">
<p id="text" class="text">Project start</p>
</div>

<div class="slider-dots">
<div id="btnOne" class="dot-box active">
<div class="dot"></div>
</div>
<div id="btnTwo" class="dot-box">
<div class="dot"></div>
</div>
<div id="btnThree" class="dot-box">
<div class="dot"></div>
</div>
<div id="btnFour" class="dot-box">
<div class="dot"></div>
</div>
</div>
</div>
</div>
</section>

<!--==================== CSS ====================-->
<script src="./main.js"></script>
</body>
</html>
66 changes: 66 additions & 0 deletions cssMemeSlider/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// ==================== SLIDER ====================
const imgOne = document.getElementById("imgOne");
const imgTwo = document.getElementById("imgTwo");
const imgThree = document.getElementById("imgThree");
const imgFour = document.getElementById("imgFour");
const text = document.getElementById("text");

const btnOne = document.getElementById("btnOne");
const btnTwo = document.getElementById("btnTwo");
const btnThree = document.getElementById("btnThree");
const btnFour = document.getElementById("btnFour");

const textImage = {
imgOne: "Project start",
imgTwo: "Night before deadline",
imgThree: "On deadline day",
imgFour: "We are ******"
};

const animateSwiping = [
{ transform: "translateX(100%)" },
{ transform: "translateX(0%)" },
];

const animateTiming = {
duration: 350,
iterations: 1
};

const changeImg = (img, btn) => {
if (imgOne.classList.value == "img img-active") {
imgOne.classList.remove("img-active");
btnOne.classList.remove("active");
};
if (imgTwo.classList.value == "img img-active") {
imgTwo.classList.remove("img-active");
btnTwo.classList.remove("active");
};
if (imgThree.classList.value == "img img-active") {
imgThree.classList.remove("img-active");
btnThree.classList.remove("active");
};
if (imgFour.classList.value == "img img-active") {
imgFour.classList.remove("img-active");
btnFour.classList.remove("active");
};

img.classList.add("img-active");
img.animate(animateSwiping, animateTiming);
btn.classList.add("active");
text.innerText = textImage[img.id];
text.animate(animateSwiping, animateTiming);
}

btnOne.addEventListener("click", () => {
changeImg(imgOne, btnOne);
})
btnTwo.addEventListener("click", () => {
changeImg(imgTwo, btnTwo);
})
btnThree.addEventListener("click", () => {
changeImg(imgThree, btnThree);
})
btnFour.addEventListener("click", () => {
changeImg(imgFour, btnFour);
})
145 changes: 145 additions & 0 deletions cssMemeSlider/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*=============== BASE ===============*/
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background: rgb(58, 58, 58);
}

/*=============== SLIDER ===============*/
.slider-container {
margin: 3.125rem;
}

.slider-images {
display: flex;
align-items: center;
overflow-x: hidden;
}

.img {
width: 100%;
height: 43.75rem;
border-radius: 0.625rem;
display: none;
}

.img-active {
display: block;
}

.slider-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: 3.125rem 0;
}

.text {
font-family: Arial, sans-serif;
font-size: 1.875rem;
line-height: 2.5rem;
color: white;
}

.slider-dots {
display: flex;
align-items: center;
gap: 0.5rem;
}

.dot-box {
padding: 0.5rem;
cursor: pointer;
border-radius: 50%;
}

.dot {
width: 1.25rem;
height: 1.25rem;
background: rgba(105, 105, 240, 0.5);
border: 0.125rem solid rgba(105, 105, 240, 0.5);
border-radius: 50%;
transition: all 0.3s;
}

.dot-box:hover .dot {
background: white;
}

.dot-box.active .dot {
background: rgb(58, 58, 58);
}

.dot-box.active:hover .dot {
border-color: white;
}


@media screen and (max-width: 1155px) {
.slider-images img {
height: 31.25rem;
}
}

@media screen and (max-width: 900px) {
.slider-images img {
height: 25rem;
}
}

@media screen and (max-width: 750px) {
.slider-container {
margin: 1.875rem;
}

.slider-images img {
height: 18.75rem;
}

.slider-card {
flex-direction: column-reverse;
gap: 1.563rem;
}

.slider-text {
width: 100%;
text-align: start;
}
}

@media screen and (max-width: 430px) {
.slider-container {
margin: 1.25rem;
}

.slider-images img {
height: 14.38rem;
}

.text {
font-size: 1.563rem;
}
}

@media screen and (max-width: 370px) {
.slider-container {
margin: 0.94rem;
}

.slider-images img {
height: 12.5rem;
}

.text {
font-size: 1.375rem;
}

.dot {
width: 1rem;
height: 1rem;
}
}
15 changes: 0 additions & 15 deletions index.html

This file was deleted.

6 changes: 0 additions & 6 deletions style.css

This file was deleted.