H5C3--transform实现任何元素居中对齐
2024-10-03 16:42:30
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style> .box{
width: 440px;
height: 500px;
background-color: #ccc;
overflow: hidden;
position: relative;
}
.son{
width: 200px;
height: 100px;
background-color: red;
margin: auto;
position: absolute;
/*定位:参照的是父容器*/
left: 50%;
top: 50%;
/*偏移:偏移中的百分比参照的是自身*/
/*定位加变化是解决居中垂直对齐问题的神器、*/
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<div class="box">
<div class="son"></div>
</div> </body>
</html>
最新文章
- javascript超过容器后显示省略号效果(兼容一行或者多行)
- ABAP 订单转交货单
- Lucene4.1 视频学习
- cacti yum快速部署
- 一种无new创建对象的方法
- VC编程中如何设置对话框的背景颜色和静态文本颜色
- Java 里把 InputStream 转换成 String 的几种方法
- Git 怎么创建本地库,向本地库提交文件
- 【转载】linux环境下为firefox/chrome浏览器安装flash player
- 专业运维配的vsftpd.conf
- Linux基础命令归纳大全
- js 两数的最大公约数
- [GNU] 喝一杯咖啡, 写一写 Makefile
- Go语言规格说明书 之 select语句(Select statements)
- Codeforces Round #322 (Div. 2) E F
- 【Python算法】遍历(Traversal)、深度优先(DFS)、广度优先(BFS)
- springboot email 中常量值 配置 mailUtils
- CVE-2017-7269—IIS 6.0 WebDAV远程代码执行漏洞分析
- 对于GTPv1协议头部的解析
- 解析 Ceph: FileJournal 的作用
热门文章
- struts2文件上传,文件类型 allowedTypes对应
- [NOIP2019模拟赛]LuoguP4261白金元首与克劳德斯
- 虚拟机上CentOS7 配置NAT模式
- Joomla - T3模板(非常好用的4屏响应式模板)
- php结合phpStudy实例来熟悉CI框架,用的软件是phpStorm+phpStudy
- opencv-VS2010配置opencv2.4.8
- C++数组或vector求最大值最小值
- Android基础控件RatingBar星级评分条的使用
- 分布式锁的Redis实现
- MySQL-Utilities:mysqldbcompare及跳过复制错误