forked from BKrishna21/CodeBits_7_rishikeshraj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
57 lines (50 loc) · 1.54 KB
/
test.html
File metadata and controls
57 lines (50 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scroll to Section</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background-color: #f8f8f8;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 200vh;
}
#section1, #section2, #section3 {
height: 100vh;
background-color: #ddd;
margin: 10px;
padding: 20px;
}
</style>
</head>
<body>
<button onclick="scrollToSection('section1')">Go to Section 1</button>
<button onclick="scrollToSection('section2')">Go to Section 2</button>
<button onclick="scrollToSection('section3')">Go to Section 3</button>
<div id="section1">
<h2>Section 1</h2>
<p>This is the content of Section 1.</p>
</div>
<div id="section2">
<h2>Section 2</h2>
<p>This is the content of Section 2.</p>
</div>
<div id="section3">
<h2>Section 3</h2>
<p>This is the content of Section 3.</p>
</div>
<script>
function scrollToSection(sectionId) {
const section = document.getElementById(sectionId);
section.scrollIntoView({ behavior: 'smooth' });
}
</script>
</body>
</html>