记录display:table的使用
2024-08-29 19:56:44
兼容性:不兼容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>
最新文章
- C#读取数据库中的表
- fibonacci封闭公式及矩阵连乘
- DHV 平常语言对话 一次聚会离场
- iOS开发——UI篇OC篇&;UIDynamic详解
- ubuntu nginx 伪静态 设置
- IOS系统对fixed定位支持不好的解决方法
- TCP报文中的SYN,FIN,ACK,PSH,RST,URG
- this web application instance has been stopped already.
- windows下python连接oracle数据库
- 接口的作用(C#)
- Oracle 经典面试题
- MySQL事务及ACID特性
- DDoS攻击流量检测方法
- ProxySQL实现Mysql读写分离 - 部署手册
- [Asp.net]Uploadify上传大文件,Http error 404 解决方案 - wolfy
- MAVEN JDK版本配置
- java基础篇---XML解析(一)
- download fomat install rootfs script
- 前端html页面学习---html部分
- 使用WebLogic时控制台输出中文乱码解决方法
热门文章
- Git使用详细教程(9):git log
- DataPipeline成功入选微软加速器 企业创新力获业界专家认可
- Windows Server 安装后无法使用无线与音频
- 使用.Net Core+IView+Vue集成上传图片功能
- C# 《编写高质量代码改善建议》整理&;笔记 --(四)资源管理&;序列化
- 【Android Studio安装部署系列】十二、Android studio代码混淆
- 总结http get和post的区别
- java的spi 的简单应用
- 微信公众号开发C#系列-1、微信公众平台注册
- MySQL优化小建议