Skip to content

Commit d698e8c

Browse files
committed
slide scroll file changed
1 parent c564bef commit d698e8c

File tree

2 files changed

+62
-37
lines changed

2 files changed

+62
-37
lines changed

slideinscroll/Style.css

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,77 @@
1+
/* Reset some default styling */
12
* {
23
margin: 0;
34
padding: 0;
4-
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
55
box-sizing: border-box;
66
scroll-behavior: smooth;
7+
8+
}
9+
10+
/* General styling */
11+
body {
12+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
13+
background-color: #f0f0f0;
14+
color: #333;
15+
line-height: 1.6;
16+
padding: 0 10vmin;
717
}
18+
819
nav {
9-
height: 8vmin;
10-
position: sticky;
20+
background-color: #2c3e50;
21+
padding: 1em 0;
22+
text-align: center;
23+
position: fixed;
1124
top: 0;
12-
display: flex;
13-
justify-content: center;
14-
align-items: center;
15-
gap: 5%;
16-
backdrop-filter: blur(10px);
17-
z-index: 9999;
25+
left: 0;
26+
width: 100%;
27+
z-index: 10;
1828
}
1929

2030
nav a {
31+
color: #ecf0f1;
32+
margin: 0 1.5em;
2133
text-decoration: none;
22-
color: black;
34+
font-size: 1.1em;
35+
transition: color 0.3s;
36+
}
37+
38+
nav a:hover {
39+
color: #f39c12;
2340
}
24-
main {
25-
height: 92vh;
26-
padding: 8vmin;
41+
42+
main,
43+
section {
2744
width: 100%;
28-
display: flex;
29-
justify-content: center;
30-
align-items: center;
31-
gap: 5%;
32-
}
33-
#about,
34-
#contact,
35-
#services {
36-
height: 100vh;
37-
padding: 8vmin;
38-
display: flex;
39-
justify-content: center;
40-
align-items: center;
41-
gap: 5%;
45+
margin: 5em auto;
46+
padding: 1em 1.5em;
47+
background-color: #ffffff;
48+
border-radius: 8px;
49+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
4250
}
51+
section {
52+
padding-top: 15vmin;
53+
}
54+
4355
img {
44-
height: 250px;
45-
transform: translate(-100px) scale(0.9);
46-
transition-duration: 0.75s;
47-
transition-delay: 0.2s;
56+
max-width: 800px;
57+
height: 400px;
58+
display: block;
59+
margin: auto;
60+
border-radius: 8px;
61+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
4862
opacity: 0;
63+
transform: scale(1) translateX(-200px);
64+
transition: all 0.75s ease .2s;
65+
;
4966
}
50-
.active {
51-
transform: translate(0) scale(1);
67+
68+
img.active {
69+
transform: scale(1.05) translateX(0);
5270
opacity: 1;
5371
}
72+
73+
p {
74+
margin: 1em 0;
75+
color: #555;
76+
line-height: 1.8;
77+
}

slideinscroll/script.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const image = document.querySelectorAll("img");
1+
const images = document.querySelectorAll("img");
2+
23
function slide() {
3-
image.forEach((el) => {
4-
const slideAt = window.scrollY + window.innerHeight + el.height /2;
4+
images.forEach((el) => {
5+
const slideAt = window.scrollY + window.innerHeight - el.height / 2;
56
const imageBottom = el.offsetTop + el.height;
67
const isHalfShown = slideAt > el.offsetTop;
78
const isNotScrolledPast = window.scrollY < imageBottom;
@@ -13,5 +14,5 @@ function slide() {
1314
});
1415
}
1516

16-
slide();
1717
window.addEventListener("scroll", slide);
18+
slide(); // Run once on page load

0 commit comments

Comments
 (0)