2008-08-12 10:33:331697 点击
将div的line-height设置与div高度一样,配合text-align:center,可实现在IE中内容垂直水平居中显示。示例如下:
CSS:
- <style type="text/css">
- .ccdiv {
- float: left;
- text-align: center;
- width: 200px;
- height: 200px;
- margin: 5px;
- border: #ccc 1px solid;
- line-height: 200px;
- }
- .ccdiv img {
- border:#666 1px dotted;
- }
- </style>
阅读全文…
技术新知
DIV,CSS,HTML,水平居中,垂直居中
2008-08-11 20:08:118466 点击
DIV水平居中显示:
定义div宽度后,设置{margin-left: auto; margin-right: auto;} 即可实现div水平居中,代码示例:
CSS:
- <style>
- .cdiv {
- width:200px;
- margin-left:auto;
- margin-right:auto;
- }
- </style>
HTML:
- <div class="cdiv">fufuok.com</div>
阅读全文…
技术新知
HTML,DIV,CSS,水平居中,垂直居中