Skip to content

Instantly share code, notes, and snippets.

@trongthanh
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trongthanh/96e8cd679e57fa94bc4f to your computer and use it in GitHub Desktop.
Save trongthanh/96e8cd679e57fa94bc4f to your computer and use it in GitHub Desktop.
Box Model Demo 2
/**
* Box Model Demo 2
*/
/*
* {
box-sizing: border-box;
}*/
/*html, body {
height: 100%;
}*/
body {
border: 1px dashed black;
/*width: 58%;*/
}
.box {
background: #ffeeee;
/*float: left;*/
border: 0 solid red;
/* ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ */
box-sizing: content-box; /* initial value */
width: 47%;
height: 100px; /* how about '%'? */
padding: 10px; /* how about % */
margin: 10px auto;
border-width: 5px;
}
<div class="box">When your browser displays an element, the element takes up space. You can think of all HTML elements as boxes. All boxes have certain dimensions and are specified by four properties: a content area of the element (e.g., a picture, a text header, etc.) and the optional padding, border and margin properties.</div>
<div class="box">The element is in the center and displays its content. Around that, there is padding. Around that, there is a border. Around that, there is a margin that separates the element from other elements.</div>
<p style="clear: both">The "edges" or the perimeters of each of the previous areas can have different properties defined on them. Thus the content edge can have a certain width or height, the padding edge that surrounds the content can have a certain width or height etc. Any or all of these sizes can be zero.</p>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"110","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment