Skip to content

Commit 9681e71

Browse files
authored
Merge branch 'main' into sticky
2 parents 1a70c17 + b2adb37 commit 9681e71

3 files changed

Lines changed: 40 additions & 11 deletions

File tree

css/style.css

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ body {
3232
overflow-x: hidden;
3333
}
3434

35+
/* html, body { overflow-x: hidden; } */
36+
3537
/* Scrollable container */
3638
.container {
3739
max-width: 1320px;
@@ -52,6 +54,7 @@ body {
5254
background-attachment: scroll;
5355
padding: 5%;
5456
margin-top: auto;
57+
margin-bottom: 0;
5558
filter: drop-shadow(0.1vw 0.1vw 0.1vw var(--bs-dark));
5659
}
5760

@@ -157,6 +160,7 @@ body {
157160
color: var(--bs-light);
158161
padding: 0;
159162
margin-bottom: 3rem;
163+
min-width: 100%;
160164
}
161165

162166
.hero-section .about-img img {
@@ -172,23 +176,32 @@ body {
172176
padding: 2rem 0;
173177
margin-bottom: 0;
174178
z-index: 1020;
179+
padding: 2rem;
180+
margin: 0;
181+
z-index: 1020;
182+
width: 100%;
183+
184+
}
185+
186+
.section-header .container {
187+
position: relative;
175188
}
176189

177190
.section-header h2 {
178191
color: var(--bs-white);
179192
margin: 0;
180193
font-size: 2.25rem;
181194
font-family: "Special Elite", system-ui;
195+
182196
}
183197

184198
.section-header::before {
185199
content: "";
186200
position: absolute;
201+
inset: 0;
187202
width: 100vw;
188-
height: 100%;
189-
top: 0;
203+
margin-left: -50vw;
190204
left: 50%;
191-
transform: translateX(-50%);
192205
background: var(--bs-dark);
193206
z-index: -1;
194207
}
@@ -197,7 +210,16 @@ body {
197210
section {
198211
position: relative;
199212
min-height: auto;
200-
margin-bottom: 0;
213+
}
214+
215+
.section-header.is-sticky {
216+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
217+
}
218+
219+
/*** Sections ***/
220+
section {
221+
position: relative;
222+
margin: 0;
201223
}
202224

203225
.section-content {
@@ -713,7 +735,7 @@ section {
713735
background: var(--bs-dark);
714736
padding: 1rem;
715737
margin-top: 0.5rem;
716-
max-height: cañc(100vh - 70px);
738+
max-height: calc(100vh - 70px);
717739
overflow-y: auto;
718740
}
719741

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<body>
4444
<!-- Navbar -->
45-
<nav class="navbar navbar-expand-lg navbar-dark">
45+
<nav class="navbar navbar-expand-lg navbar-dark" data-bs-spy="scroll" data-bs-target="#navbarNav" data-bs-root-margin="0px 0px -40%" data-bs-smooth-scroll="true">
4646
<div class="container-fluid">
4747
<div class="container position-relative">
4848
<div class="d-flex justify-content-between align-items-center w-100">

js/main.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,34 @@
3535
return false;
3636
});
3737

38+
3839
// Simple navbar scroll spy
3940
document.addEventListener("DOMContentLoaded", function () {
40-
var scrollSpy = new bootstrap.ScrollSpy(document.body, {
41-
target: "#navbarNav",
42-
offset: 100,
41+
const dataSpyList = document.querySelectorAll('[data-bs-spy="scroll"]');
42+
dataSpyList.forEach((dataSpyEl) => {
43+
bootstrap.ScrollSpy.getOrCreateInstance(dataSpyEl, {
44+
target: "#navbarNav",
45+
offset: 100,
46+
smoothScroll: true,
47+
});
4348
});
4449

4550
document.querySelectorAll(".navbar-nav a.nav-link").forEach((link) => {
4651
link.addEventListener("click", function (e) {
4752
if (this.hash !== "") {
4853
e.preventDefault();
4954
const hash = this.hash;
50-
5155
document.querySelector(hash).scrollIntoView({
5256
behavior: "smooth",
5357
});
5458

55-
// Close mobile menu after clicking
59+
// En móvil cerrar tras pulsar un enlace
60+
5661
const navbarToggle = document.querySelector(".navbar-toggler");
5762
if (window.getComputedStyle(navbarToggle).display !== "none") {
5863
document.querySelector(".navbar-collapse").classList.remove("show");
5964
}
65+
6066
}
6167
});
6268
});
@@ -100,6 +106,7 @@
100106
// Observe each section
101107
document.querySelectorAll("section").forEach((section) => {
102108
observer.observe(section);
109+
103110
});
104111
});
105112
})(jQuery);

0 commit comments

Comments
 (0)