Table控件及内容居中
2016-04-16 13:24
621 查看
Table控件居中
整个Table控件居中
方法一<head> <style type="text/css"> table { width:40%; margin:0 30%;/*40+30+30=100,所以居中*/ } </style> </head> <body > <form> <h1>表格</h1> <div> <table> <tr> <th>FirstName</th> <th>LastName</th> </tr> <tr> <td>Bill</td> <td>Gates</td> </tr> </table> </div> </form> </body>
方法二
<head> <style type="text/css"> table { width:40%; margin:auto;/*浏览器自动解释为居中,没有验证所有浏览器都支持*/ } </style> </head> <body > <form> <h1>表格</h1> <div> <table> <tr> <th>FirstName</th> <th>LastName</th> </tr> <tr> <td>Bill</td> <td>Gates</td> </tr> </table> </div> </form> </body>
方法三
<head> <style type="text/css"> table { width:40%; } </style> </head> <body > <form> <h1>表格</h1> <div> <center><!--Html中的居中--> <table> <tr> <th>FirstName</th> <th>LastName</th> </tr> <tr> <td>Bill</td> <td>Gates</td> </tr> </table> </center> </div> </form> </body>
内容居中
<head> <style type="text/css"> table { width:40%; } td,th { border:1px solid green; border-collapse:collapse;/*是否将边框合成一个*/ padding:5px; border-spacing:10px; text-align:center;/*水平对齐方式*/ vertical-align:bottom;/*垂直对齐方式*/ } </style> </head> <body > <form> <h1>表格</h1> <div> <table> <tr> <th>FirstName</th> <th>LastName</th> </tr> <tr> <td>Bill</td> <td>Gates</td> </tr> </table> </div> </form> </body>
相关文章推荐
- html和css,其实,对于女孩子来说,挺容易的咯
- 对于在div或ul li 中加入图片有各种空隙的小研究
- HTML和CSS基础知识
- 改变图片样式
- 深入理解CSS中的margin负值
- 15 个非常棒的 CSS3 效果教程
- 深入理解CSS浮动
- 深入理解CSS绝对定位
- CSS------添加注释框
- 用图片做div背景的列表布局 CSS代码
- (转)Google的编程样式
- CSS 奇技淫巧十八招
- 关于CSS伪类选择器
- html+css写个blog首页
- CSS Sprite、CSS雪碧图应用实例
- CSS中一些@规则的用法小结
- POI之Excel单元格样式
- Css基本样式(二)
- display:inline、block、inline-block的区别
- CSS3的新属性animation