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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>CSS Background Tests</title>
<style>
.example {
width: 45%;
display: inline-block;
}
.box {
width: 180px;
height: 160px;
border: 1px solid black;
padding: 5px 10px 15px 20px;
overflow: auto;
}
.force-scroll {
width: 500px;
height: 500px;
}
code {
display: block;
}
</style>
</head>
<body>
<h1>CSS Background Tests</h1>
<p>These are in no way exhaustive, but they cover a variety of different features.</p>
<p>The left and right columns should look identical - left uses a single background shorthand, and right uses separate properties.</p>
<h2>Attachment</h2>
<h3>Should remain motionless relative to the browser window</h3>
<div class="example">
<code>background: url('background-repeat.png') fixed</code>
<div class="box" style="background: url('background-repeat.png') fixed">
<div class="force-scroll"></div>
</div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-attachment: fixed;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-attachment: fixed;">
<div class="force-scroll"></div>
</div>
</div>
<h3>Should scroll with box content</h3>
<div class="example">
<code>background: url('background-repeat.png') local</code>
<div class="box" style="background: url('background-repeat.png') local">
<div class="force-scroll"></div>
</div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-attachment: local;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-attachment: local">
<div class="force-scroll"></div>
</div>
</div>
<h3>Should remain motionless relative to the box</h3>
<div class="example">
<code>background: url('background-repeat.png') scroll</code>
<div class="box" style="background: url('background-repeat.png') scroll">
<div class="force-scroll"></div>
</div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-attachment: scroll;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-attachment: scroll">
<div class="force-scroll"></div>
</div>
</div>
<h2>Position</h2>
<div class="example">
<code>background: url('background-repeat.png') bottom 5% right 10px no-repeat</code>
<div class="box" style="background: url('background-repeat.png') bottom 5% right 10px no-repeat"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-position: bottom 5% right 10px no;<br/>
background-repeat: no-repeat;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-position: bottom 5% right 10px; background-repeat: no-repeat"></div>
</div>
<h2>Clip and Origin</h2>
<h3>Images should fill the content-box, with padding on each side. (5px, 10px, 15px, 20px) and aligned so their top-left corner will be at the top-left of the box. This produces clipping.</h3>
<div class="example">
<code>background: url('background-repeat.png') yellow padding-box content-box</code>
<div class="box" style="background: url('background-repeat.png') yellow padding-box content-box"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-color: yellow;<br/>
background-origin: padding-box;<br/>
background-clip: content-box;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-color: yellow; background-origin: padding-box; background-clip: content-box"></div>
</div>
<h2>Size</h2>
<h3>Image should be stretched as large as the box, without distorting or clipping</h3>
<div class="example">
<code>background: url('background-repeat.png') center / contain</code>
<div class="box" style="background: url('background-repeat.png') center / contain"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-position: center;<br/>
background-size: contain;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-position: center; background-size: contain"></div>
</div>
<h3>Image should be stretched so that the whole box is covered, without distorting</h3>
<div class="example">
<code>background: url('background-repeat.png') center / cover</code>
<div class="box" style="background: url('background-repeat.png') center / cover"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');
background-position: center;
background-size: cover;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-position: center; background-size: cover"></div>
</div>
<h3>Images should be squashed and repeated</h3>
<div class="example">
<code>background: url('background-repeat.png') top / 50% 25px</code>
<div class="box" style="background: url('background-repeat.png') top / 50% 25px"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');
background-position: top;
background-size: 50% 25px;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-position: top; background-size: 50% 25px"></div>
</div>
<h2>Repeat</h2>
<p>See <a href="background-repeat-test.html">here</a> for in-depth background-repeat tests.</p>
<h3>Images should all be whole, and be spaced apart to fill the box</h3>
<div class="example">
<code>background: url('background-repeat.png') space</code>
<div class="box" style="background: url('background-repeat.png') space"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');
background-repeat: space;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-repeat: space"></div>
</div>
<h3>Images should all be whole, and be distorted to fill the box</h3>
<div class="example">
<code>background: url('background-repeat.png') round</code>
<div class="box" style="background: url('background-repeat.png') round"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-repeat: round;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-repeat: round"></div>
</div>
<h3>Images should all be whole, and be shrunk and spaced to fill the box</h3>
<div class="example">
<code>background: url('background-repeat.png') space round</code>
<div class="box" style="background: url('background-repeat.png') space round"></div>
</div>
<div class="example">
<code>
background-image: url('background-repeat.png');<br/>
background-repeat: space round;
</code>
<div class="box" style="background-image: url('background-repeat.png'); background-repeat: space round"></div>
</div>
<h2>Multiple backgrounds</h2>
<h3>Should have one smiley face in each corner and one in the center</h3>
<div class="example">
<code>
background: url('background-repeat.png') no-repeat top 5px left 5px,<br/>
url('background-repeat.png') no-repeat top 5px right 5px,<br/>
url('background-repeat.png') no-repeat bottom 5px left 5px,<br/>
url('background-repeat.png') no-repeat bottom 5px right 5px,<br/>
url('background-repeat.png') no-repeat center cyan;
</code>
<div class="box" style="background: url('background-repeat.png') no-repeat top 5px left 5px, url('background-repeat.png') no-repeat top 5px right 5px, url('background-repeat.png') no-repeat bottom 5px left 5px, url('background-repeat.png') no-repeat bottom 5px right 5px, url('background-repeat.png') no-repeat center cyan"></div>
</div>
<div class="example">
<code>
background-color: cyan;<br/>
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;<br/>
background-position: top 5px left 5px, top 5px right 5px, bottom 5px left 5px, bottom 5px right 5px, center;<br/>
background-image: url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png');
</code>
<div class="box" style="background-color: cyan;
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
background-position: top 5px left 5px, top 5px right 5px, bottom 5px left 5px, bottom 5px right 5px, center;
background-image: url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png'), url('background-repeat.png');"></div>
</div>
</body>
</html>
|