-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
50 lines (42 loc) · 1.39 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Fix Element Sizing with CSS Border Box</title>
<link type="text/css" href="styles.css" media="screen" rel="Stylesheet" />
<link href="themes/obsidian.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<span id="forkongithub">
<a href="https://github.com/SoftwareAddictionShow/css-fix-element-sizing">Fork me on GitHub</a>
</span>
<h1>Fix Element Sizing with CSS Border Box</h1>
<p>
By default, an element size does not include the border or padding.
With Border Box, the element padding and border is included in its size.
</p>
<iframe src="default.html" width="300" height="600">
</iframe>
<iframe src="border_box.html" width="300" height="600">
</iframe>
<p>
We can apply Border Box to all elements (and pseudo elements), by using this CSS:
</p>
<pre><code data-language="css">
*, *::before, *::after {
box-sizing: border-box;
}
</code></pre>
<h2>Sources:</h2>
<p>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing#Browser_compatibility">
https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing#Browser_compatibility
</a>
</p>
</body>
<script src="js/rainbow.js"></script>
<script src="js/language/generic.js"></script>
<script src="js/language/css.js"></script>
<script>
</script>
</html>