-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss_position_1.html
More file actions
155 lines (151 loc) · 4.45 KB
/
css_position_1.html
File metadata and controls
155 lines (151 loc) · 4.45 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible", content="IE-edge">
<title>Position | Vijay CSS</title>
<link rel="stylesheet", href="css/style.css">
<link rel="stylesheet", href="css/fonts.css">
<link rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"> <!--Import more fonts from font-awesome-->
<style>
html {scroll-behavior: smooth;}
body
{
font-family: Arial;
font-size: 2rem;
min-height: 200vh;
}
.outer-container
{
border: 3px dashed black;
width: 75vw;
height: 85vh;
margin: 40px auto;
position: relative;
}
.inner-container
{
border: 2px solid blue;
width: 40vw;
height: 50vh;
margin: 200px auto;
}
.box
{
width: 150px;
height: 150px;
color: white;
padding: 1rem;
}
.absolute
{
background-color: yellow;
color: black;
position: absolute;
top: 0;
left: 0;
z-index: 1; /* overlap absolute block over fixed */
}
.relative
{
background-color: red;
color: black;
position: relative;
top: 300px; /* shift box 100px down */
left: 100px; /* shift box 100px right */
}
.fixed
{
background-color: green;
color: black;
position: fixed;
top: 100px;
}
.sticky
{
background-color: blue;
color: black;
position: sticky;
top: 0;
}
/* Social Media Icons */
section
{
height: 100vh;
}
.blue {background-color: blue; margin: -2rem;}
.red {background-color: red;}
.green {background-color: green;}
header, footer
{
color: white;
text-align: center;
height: 100px;
}
header
{
position: sticky;
top: 0;
font-size: 5rem;
}
footer
{
background-color: black;
position: sticky;
bottom: 0;
width: 100%;
font-size: 3rem;
}
footer a {color: blue;}
footer a:visited {color: white;}
.social
{
background-color: royalblue;
color: white;
font-size: inherit;
padding: 1rem;
position: fixed;
top: 30%;
left: 0;
z-index: 1; /* overlap all contents */
}
</style>
</head>
<body>
<!-- <div class="outer-container">
<div class="inner-container">
<div class="box absolute">
<p>Absolute</p>
</div>
<div class="box relative">
<p>Relative</p>
</div>
<div class="box fixed">
<p>Fixed</p>
</div>
<div class="box sticky">
<p>Sticky</p>
</div>
</div>
</div> -->
<button class="social">Social</button>
<section id="one">
<header class="blue">Header One</header>
<h2>One</h2>
</section>
<section id="two">
<header class="red">Header Two</header>
<h2>Two</h2>
</section>
<section id="three">
<header class="green">Header Three</header>
<h2>Three</h2>
</section>
<footer>
<a href="#one">One</a>
<a href="#two">Two</a>
<a href="#three">Three</a>
</footer>
</body>
</html>