-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter17.html
More file actions
192 lines (177 loc) Β· 7.58 KB
/
chapter17.html
File metadata and controls
192 lines (177 loc) Β· 7.58 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chapter 17: CSS Backgrounds</title>
<link rel="stylesheet" href="style.css">
<style>
.tag-demo { margin: 10px 0; }
.head-demo { border: 1px solid #ccc; padding: 10px; margin: 5px 0; }
.bg-box { width: 300px; height: 150px; border: 1px solid red; margin: 5px 0; }
.sprite { display: inline-block; width:50px; height:50px; margin:5px; background-image: url('myName.png'); border-radius: 5px; }
.navlist {
display: flex;
justify-content: space-between;
width: 300px;
margin: 20px auto;
padding: 0;
}
.navlist li {
list-style: none;
border-radius: 3px;
}
.navlist a {
align-items: center;
text-align: center;
display: block;
border-radius: 5px;
text-decoration: none;
color: rgb(0, 0, 0);
width: 55px;
height: 40px;
background-image: url("myName.png"); /* make sure this file exists */
background-repeat: no-repeat;
}
.home a { background-position: 0 0; }
.prev a { background-position: -50px 0; }
.next a { background-position: -100px 0; }
</style>
</head>
<body>
<h2 class="chapter-header" id="home">Chapter 17: CSS Backgrounds</h2>
<!-- Background Color -->
<div class="tag-section">
<h3>Background Color</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background-color: yellow;">Background Color Yellow</p>
</div>
</div>
</div>
<!-- Background Image -->
<div class="tag-section">
<h3>Background Image</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background-image: url('bg.jpg'); color:#2b0606;">Single Background Image</p>
<p class="bg-box" style="background-image: url('another-bg.png'), url('bg.jpg'); color:#2b0606;">Multiple Background Images</p>
</div>
</div>
</div>
<!-- Background Repeat -->
<div class="tag-section">
<h3>Background Repeat</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: repeat-x;">Repeat-X</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: repeat-y;">Repeat-Y</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: space;">Space</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: round;">Round</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat;">No Repeat</p>
</div>
</div>
</div>
<!-- Background Position -->
<div class="tag-section">
<h3>Background Position</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat; background-position: right top;">Right Top</p>
</div>
</div>
</div>
<!-- Background Size -->
<div class="tag-section">
<h3>Background Size</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat; background-size: 100px 100px;">100px 100px</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat; background-size: 50% 66%;">50% 66%</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat; background-size: contain;">Contain</p>
<p class="bg-box" style="background-image: url('bg.jpg'); background-repeat: no-repeat; background-size: cover;">Cover</p>
<p class="bg-box" style="background: #ff0 url('bg.jpg') no-repeat right top;">Shorthand Example</p>
</div>
</div>
</div>
<!-- Background Clip -->
<div class="tag-section">
<h3 id="prev">Background Clip</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="border:10px dotted black; padding:20px; background:yellow;">Default (Border-box)</p>
<p class="bg-box" style="border:10px dotted black; padding:20px; background:yellow; background-clip: padding-box;">Padding-box</p>
<p class="bg-box" style="border:10px dotted black; padding:20px; background:yellow; background-clip: content-box;">Content-box</p>
</div>
</div>
</div>
<!-- Background Origin -->
<div class="tag-section">
<h3>Background Origin</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="border:5px solid red; padding:35px; background:url(bg.jpg) no-repeat;">Default (Padding-box)</p>
<p class="bg-box" style="border:5px solid red; padding:35px; background:url(bg.jpg) no-repeat; background-origin: border-box;">Border-box</p>
<p class="bg-box" style="border:5px solid red; padding:35px; background:url(bg.jpg) no-repeat; background-origin: content-box;">Content-box</p>
</div>
</div>
</div>
<!-- Background Attachment -->
<div class="tag-section">
<h3>Background Attachment</h3>
<div class="tag-demo">
<div class="head-demo">
<div style="height:500px; background-image:url('bg.jpg'); background-repeat:no-repeat; background-attachment: fixed; background-position:center 60px;">Fixed Background</div>
<p class="bg-box" style="overflow:auto; height:200px; background-image:url('bg.jpg'); background-repeat:no-repeat; background-attachment: local;">Local Background (scrolls with content)</p>
</div>
</div>
</div>
<!-- CSS Gradients -->
<div class="tag-section">
<h3>CSS Gradients</h3>
<div class="tag-demo">
<div class="head-demo">
<p class="bg-box" style="background: linear-gradient(red, yellow);">Linear Gradient Top to Bottom</p>
<p class="bg-box" style="background: linear-gradient(to right, red, yellow);">Linear Gradient Left to Right</p>
<p class="bg-box" style="background: linear-gradient(to bottom right, red, yellow);">Diagonal Gradient</p>
<p class="bg-box" style="background: linear-gradient(-90deg, red, yellow);">Angle Gradient</p>
<p class="bg-box" style="background: repeating-linear-gradient(red, yellow 30%, green 50%);">Repeating Linear Gradient</p>
<p class="bg-box" style="background: radial-gradient(red, yellow, green);">Radial Gradient</p>
<p class="bg-box" style="background: radial-gradient(red 10%, yellow 30%, green 60%);">Radial Gradient with Stops</p>
<p class="bg-box" style="background: repeating-radial-gradient(red, yellow 10%, green 20%);">Repeating Radial Gradient</p>
</div>
</div>
</div>
<!-- CSS Sprites -->
<div class="tag-section">
<h3 id="next">CSS Sprites</h3>
<div class="tag-demo">
<div class="head-demo">
<div class="sprite testing"></div>
<div class="sprite number-1"></div>
<div class="sprite number-2"></div>
<div class="sprite number-3"></div>
<div class="sprite number-4"></div>
<div class="sprite number-5"></div>
<div class="sprite number-6"></div>
<div class="sprite number-7"></div>
<div class="sprite number-8"></div>
<div class="sprite number-9"></div>
</div>
</div>
</div>
<!-- Navigation Sprites -->
<div class="tag-section">
<h3>Navigation Sprites</h3>
<div class="tag-demo">
<div class="head-demo">
<ul class="navlist">
<li class="sprite home"><a href="#home">Top</a></li>
<li class="sprite prev"><a href="#prev">Middle</a></li>
<li class="sprite next"><a href="#next">Last</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>