Skip to content

Instantly share code, notes, and snippets.

@zhangwc
Created December 4, 2013 10:50
Show Gist options
  • Save zhangwc/7785696 to your computer and use it in GitHub Desktop.
Save zhangwc/7785696 to your computer and use it in GitHub Desktop.
#main {
max-width: 600px;
margin: 0 auto;
}
最大宽度600px,并居中。
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
忽略元素盒模型的内边距和边框。
position属性
static —— 默认,表示它不会被特殊定位
relative —— 相对定位,可以修改top\right\bottom\left属性使其偏离正常位置
fixed —— 固定在相对窗口的位置,不会再变动
absolute —— absolute 与 fixed 的表现类似,除了它不是相对于视窗而是相对于最近的“positioned”祖先元素。如果绝对定位(position属性的值为absolute)的元素没有“positioned”祖先元素,那么它是相对于文档的 body 元素,并且它会随着页面滚动而移动。
float —— 实现文字环绕图片
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment