html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!-- this code is originally from W3School
from its box-shadow tutorial -->
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="card">
<div class="header">
<h1>1</h1>
</div>
<div class="container">
<p>January 1, 2016</p>
</div>
</div>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
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
div.card {
width: 250px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
text-align: center;
}
div.header {
background-color: blue;
color: white;
/* //// Question:
why the header's box size suddenly collapses
when the bottom and top paddings are set
to zero?
answer: later I found out it's due to
sth called "margin collapsing".by adding
padding it is automatically prevented
it can be prevented in various other ways
/// */
padding: 10px 0px;
font-size: 40px;
}
div.container {
padding: 10px;
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run