兼容性:不兼容IE7

1.左右对齐

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title>左右两端布局</title>
<style> .table {
display: table;
border: 1px solid #06c;
padding: 15px;
width: 100%;
} .table .table-left {
text-align: left;
display: table-cell
} .table .table-right {
text-align: right;
display: table-cell
} .table .table-content {
width: 100px;
height: 100px;
border: 1px solid #ccc;
text-align: center;
display: inline-block;
font-size: 40px;
line-height: 100px;
}
</style>
</head> <body>
<div class="table">
<div class="table-left">
<div class="table-content">左边</div>
</div>
<div class="table-right">
<div class="table-content">右边</div>
</div>
</div>
</body> </html>

2.居中

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title>图片居中对齐</title>
<style>
* {
box-sizing: border-box;
} .table {
display: table;
border: 1px solid #06c;
padding: 5px;
max-width: 1000px;
margin: 10px auto;
width: 100%;
} .table-center {
height: 150px;
width: 100px;
border: 1px solid red;
display: table-cell;
vertical-align: middle;
text-align: center;
background-color: #4679bd;
}
</style>
</head> <body>
<div class="table">
<div class="table-center">
<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556086970323&di=51c11bb425e5f92ca3c9e455aad95675&imgtype=0&src=http%3A%2F%2Fpic.58pic.com%2F58pic%2F13%2F20%2F57%2F95i58PIC6Qh_1024.jpg" width="50px" height="50px" alt="logo" />
</div>
</div>
</body> </html>

3.平均分

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title>平均分</title>
<style>
* {
box-sizing: border-box;
} .table {
display: table;
border: 1px solid #000;
padding: 5px;
max-width: 1000px;
margin: 0 auto;
width: 100%;
} .table ul {
display: table;
width: 100%;
padding: 0;
border-right: 1px solid #ccc;
} .table ul li {
display: table-cell;
border: 1px solid #ccc;
text-align: center;
height: 100px;
border-right: none;
line-height: 100px;
}
</style>
</head> <body>
<div class="table">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</body> </html>

最新文章

  1. C#读取数据库中的表
  2. fibonacci封闭公式及矩阵连乘
  3. DHV 平常语言对话 一次聚会离场
  4. iOS开发——UI篇OC篇&amp;UIDynamic详解
  5. ubuntu nginx 伪静态 设置
  6. IOS系统对fixed定位支持不好的解决方法
  7. TCP报文中的SYN,FIN,ACK,PSH,RST,URG
  8. this web application instance has been stopped already.
  9. windows下python连接oracle数据库
  10. 接口的作用(C#)
  11. Oracle 经典面试题
  12. MySQL事务及ACID特性
  13. DDoS攻击流量检测方法
  14. ProxySQL实现Mysql读写分离 - 部署手册
  15. [Asp.net]Uploadify上传大文件,Http error 404 解决方案 - wolfy
  16. MAVEN JDK版本配置
  17. java基础篇---XML解析(一)
  18. download fomat install rootfs script
  19. 前端html页面学习---html部分
  20. 使用WebLogic时控制台输出中文乱码解决方法

热门文章

  1. Git使用详细教程(9):git log
  2. DataPipeline成功入选微软加速器 企业创新力获业界专家认可
  3. Windows Server 安装后无法使用无线与音频
  4. 使用.Net Core+IView+Vue集成上传图片功能
  5. C# 《编写高质量代码改善建议》整理&amp;笔记 --(四)资源管理&amp;序列化
  6. 【Android Studio安装部署系列】十二、Android studio代码混淆
  7. 总结http get和post的区别
  8. java的spi 的简单应用
  9. 微信公众号开发C#系列-1、微信公众平台注册
  10. MySQL优化小建议