Skip to content
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Slider

- Had problem while making the image disappear
- Added animation now and now this slider is as per the description
Binary file removed img-1.jpeg
Binary file not shown.
Binary file removed img-2.jpeg
Binary file not shown.
Binary file removed person-1.jpeg
Binary file not shown.
4 changes: 4 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ function createImage(src, alt, dataId) {
imgContainer.innerHTML = ''
// creation of image
const image = document.createElement('img')
// added class that makes image responsive
image.classList.add('responsive-img')
// added class that helps in animation
image.classList.add('fade')

image.setAttribute('src', src)
image.setAttribute('alt', alt)
image.setAttribute('data-id', dataId)
Expand Down
21 changes: 20 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
/* this might eat the part of image if the images dont respect the aspect ratio of 1:1*/
/* this might eat the part of image
if the images don't respect the aspect ratio */
height: 50%;
width: 50%;
/* background-color: red; */
Expand Down Expand Up @@ -52,3 +53,21 @@
cursor: pointer;
color: #fff;
}
/* animation */
/* inspired from w3school*/

.fade {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
0% {
opacity: 0.2;
}
50% {
opacity: 0.6;
}
100% {
opacity: 1;
}
}