Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:13
Show Gist options
  • Save st98/3b49ff40242c5ed9d218 to your computer and use it in GitHub Desktop.
Save st98/3b49ff40242c5ed9d218 to your computer and use it in GitHub Desktop.
box-sizing の挙動を確かめたかった。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>box-sizing-1</title>
<style>
* {
margin: 0;
padding: 0;
font-family: Consolas;
}
div {
width: 25px;
height: 25px;
margin: 2px;
border: 2px solid black;
}
#content-box {
background: red;
box-sizing: content-box;
}
#padding-box {
background: green;
box-sizing: padding-box;
}
#border-box {
background: blue;
box-sizing: border-box;
}
</style>
</head>
<body>
<h1>box-sizing-1</h1>
<h2>content-box</h2>
<div id="content-box"></div>
<h2>padding-box</h2>
<div id="padding-box"></div>
<h2>border-box</h2>
<div id="border-box"></div>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>box-sizing-2</title>
<style>
* {
margin: 0;
padding: 0;
font-family: Consolas;
}
.container {
width: 50px;
height: 50px;
border: 2px solid #000;
}
h2::before {
display: block;
content: '';
clear: both;
}
.box {
float: left;
border: 2px solid #000;
width: 50%;
height: 100%;
}
.content-box {
box-sizing: content-box;
background: #f00;
}
.border-box {
box-sizing: border-box;
background: #00f;
}
</style>
</head>
<body>
<h1>box-sizing-2</h1>
<h2>content-box</h2>
<div class="container"><div class="box content-box"></div><div class="box content-box"></div></div>
<h2>border-box</h2>
<div class="container"><div class="box border-box"></div><div class="box border-box"></div></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment