-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponsive-grid-css-diy.html
70 lines (62 loc) · 1.52 KB
/
responsive-grid-css-diy.html
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
<!DOCTYPE html>
<html>
<head>
<title>DIY Responsive Grid</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style type="text/css">
/* -----------Smartphone View----------- */
@media only screen and (max-width : 480px) {
.tile {
width: 100%;
}
}
/* -----------Desktop View----------- */
@media only screen and (min-width : 481px) {
.tile {
width: 40%;
}
}
/* -----------Universal Views----------- */
html, body {
height: 100%;
margin: 0 auto;
}
.tile {
/*height: 40%; Height cannot be used due to the fact that it scales based on content */
padding-bottom: 40%; /*by using padding-bottom the positioning allows for content to be rendered consistanly */
background-color: blue;
margin: 5%;
position: relative; /* the container needs to be needs to be relative if the contents will be absolute */
float: left;
overflow: hidden;
}
.content {
position: absolute; /* needs to be absolute so the parent container does not use it in sizing calculations */
}
</style>
</head>
<body>
<div class='tile'>
<div class='content'>
Some sort of content is inside each of these! Number 1!
</div>
</div>
<div class='tile'>
<div class='content'>
Some sort of content is inside each of these! Number 2!
</div>
</div>
<div class='tile'>
<div class='content'>
Some sort of content is inside each of these! Number 3!
</div>
</div>
<div class='tile'>
<div class='content'>
Some sort of content is inside each of these! Number 4!
</div>
</div>
</body>
<script>
</script>
</html>