CSS2【3】-- Positioning
2016-03-14 17:36
561 查看
The Box Model
![](https://img-blog.csdn.net/20160314130146539)
display
![](https://img-blog.csdn.net/20160314155927416)
![](https://img-blog.csdn.net/20160314155944562)
![](https://img-blog.csdn.net/20160314160007125)
![](https://img-blog.csdn.net/20160314160018438)
Margins、Borders、and Padding
![](https://img-blog.csdn.net/20160314161656251)
Margin
![](https://img-blog.csdn.net/20160314162901110)
Borders
Padding
![](https://img-blog.csdn.net/20160314163844595)
Negative Values
display
the display property. We'll learn about four possible values. ***block***: This makes the element a block box. It won't let anything sit next to it on the page! It takes up the full width. ***inline-block***: This makes the element a block box, but will allow other elements to sit next to it on the same line. ***inline***: This makes the element sit on the same line as another element, but without formatting it like a block. It only takes up as much width as it needs (not the whole line). ***none***: This makes the element and its content disappear from the page entirely!
Margins、Borders、and Padding
The ***margin*** is the space around the element. The larger the margin, the more space between our element and the elements around it. We can adjust the margin to move our HTML elements closer to or farther from each other. The ***border*** is the edge of the element. It's what we've been making visible every time we set the border property. The ***padding*** is the spacing between the content and the border. We can adjust this value with CSS to move the border closer to or farther from the content. The ***content*** is the actual "stuff" in the box. If we're talking about a <p> element, the "stuff" is the text of the paragraph. You'll see abbreviations like TM, TB, and TP in the diagram. These stand for "top margin," "top border," and "top padding." As we'll see, we can adjust the top, right, left, and bottom padding, border, and margin individually.
Margin
margin: auto; 居中,center our div
margin-top: /*some value*/ margin-right: /*some value*/ margin-bottom: /*some value*/ margin-left: /*some-value*/
Borders
border: 2px solid black;
Padding
padding-top: /*some value*/ padding-right: /*some value*/ padding-bottom: /*some value*/ padding-left: /*some-value*/
padding: value value value value;
Negative Values
If you want to move an element in the other direction, you can give CSS a negative value: margin-left: -20px will move the element twenty pixels to the left.
相关文章推荐
- Web布局连载——两栏固定布局(五)
- [div+css]晒晒最新制作专题推广页模板
- 盒子模型
- CSS选择器
- CSS样式优先权
- [css] line-height 百分比单位和数值单位的区别
- Apple官网研究之使用Justify布局导航
- 设计更快的网页(三):字体和 CSS 调整
- 纯CSS制作的新闻网站中的文章列表
- 10条影响CSS渲染速度的写法与使用建议第1/3页
- BS项目中的CSS架构_仅加载自己需要的CSS
- 很不错的 CSS Hack 又学了一招
- 发一个css比较清爽的写法
- CSS expression控制图片自动缩放效果代码[兼容 IE,Firefox]
- css布局网页水平居中常用方法
- CSS经典技巧十则第1/2页
- css 兼容性问题this.style.cursor=''hand''
- IE6不能正常解析CSS文件问题的解决方法及原因分析
- 欲练CSS ,必先解决IE的一些细节分析
- CSS文字截取功能实现代码