HTML - 浅谈DIV盒子居中
2014-12-25 11:18
232 查看
<html> <head><title>postion方式的居中</title> <style> div{ width: 200px ; height: 200px ; background: red ; position: absolute ; left: 50% ; top: 50% ; margin-top: -100px ; margin-left: -100px ; } </style> </head> <body> <div></div> </body> </html>
以上是使用postion的方式来使得DIV上下左右一直在中间,DIV的大小不会变。
<html> <head><title>margin方式的居中</title> <style> body{ margin: 0px; padding: 200px; } div{ width: 100% ; height: 100% ; background: red ; } </style> </head> <body> <div></div> </body> </html>
以上是使用margin的方式是的DIV居中,他的形状取决于什么,希望大家自己仔细看看。
相关文章推荐
- html div 水平垂直居中
- css未盒子div居中的多种方法
- html在一行内横向排列并排同行同时显示两个多个div盒子的方法(CSS浮动清除float-clear/inline)/办法
- Html DIV居中显示
- css让div水平垂直居中,用弹性盒子
- div盒子水平垂直居中的方法
- HTML中一个div中关于其内容的水平和垂直居中
- html div左右/垂直居中
- HTML:div内容上下居中
- HTML的DIV如何实现垂直居中
- html 中 div不定宽度如何水平居中的解决方案
- html中div垂直居中
- 浅谈CSS+DIV盒子的相对和绝对定位
- Div上下居中 (html)
- div盒子水平垂直居中方法
- html/css 图片在div内居中。
- HTML的DIV如何实现水平居中
- html 中div垂直居中的三种方式
- html div垂直居中的设置
- div浮动居中 单div盒子和三列布局中间div盒子浮动居中方法