用CSS样式让div内元素垂直居中
更新时间:2023-03-29 10:38:01 阅读量: 建筑文档 文档下载
- css样式div居中推荐度:
- 相关推荐
用CSS样式让p内元素垂直居中
<style>
body {padding: 0; margin: 0;}
body,html{height: 100%;}
#outer {height: 100%; overflow: hidden; position: relative;width: 100%; background:ivory;}
#outer[id] {display: table; position: static;}
#middle {position: absolute; top: 50%;} /* for explorer only*/
#middle[id] {display: table-cell; vertical-align: middle; position: static;}
#inner {position: relative; top: -50%;width: 400px;margin: 0 auto;} /* for explorer only */
p.greenBorder {border: 1px solid green; background-color: ivory;}
</style>
<p id="outer">
<p id="middle">
<p id="inner" class="greenBorder">5535435
</p>
</p>
</p>
标准浏览器如Mozilla, Opera, Safari等,可将:
父级元素显示方式设定为:TABLE(display: table;) ,
内部子元素定为table-cell (display: table-cell),
通过vertical-align特性使其垂直居中,但非标准浏览器是不支持的。
非标准浏览器只能在子元素里设距顶部50%,里面再套个元素距顶部-50% 来抵消。
正在阅读:
用CSS样式让div内元素垂直居中03-29
局域网管理(windows平台)windows+2000试题汇编题目05-07
家族企业的人类学研究:视角和方法05-31
暑期社会实践报告(推荐43篇)03-31
防溺水高一满分作文800字10篇03-27
武汉江岸区2017-2018学年度第一学期七年级综合素质测试试题数学试卷(word版)01-10
商务局上年工作总结及下年工作计划04-27
岗位职责汇编工程部206-09
2018最新冀教版四年级数学下册全册教案(含教学计划进度)07-29
电子显微镜的现状05-18
- 在担当责任中培养主人翁意识
- 疫苗信任危机下的自我救赎
- 2015年湖南省农村信用社招考复习资料
- 《草原》课外阅读:五月的青岛(老舍)
- 最低生活保障申请审批流程
- 2015年中央财经大学保险硕士考研经验汇总@才思
- 司法考试必备—民法笔记(4)
- 2012初级会计实务讲义--行政事业单位会计
- 论东北三省跨界民族非物质文化遗产保护方式
- M4735A-SHANGHAI除颤仪
- 《那一年,面包飘香》
- word上机操作基础试题
- 用双脚弹钢琴的人
- 关于学会感恩的作文
- 2014年一月货币基金BR收益排名
- 二年级语文下册《画风》教学设计及教学反思
- 公因数和最大公因数 0
- 水产用药常识及注意事项
- 通用电气对中国的借鉴意义
- 龙年束姓女孩大气雅致取名大全
- 居中
- 垂直
- 样式
- 元素
- CSS
- div
- 导数在实际生活中的应用(一)
- 健康体检专家共识ppt课件
- 第二章实数单元测试
- 2016年西北民族大学新闻传播学院826传播学理论之《中国新闻传播
- 智鼎IQT大学生思维能力测验9.11
- 抗日英雄杨靖宇的故事
- 小学教师年度考核工作总结
- 大学毕业唯美的句子
- 资源节约循环利用重点工程2016年中央预算内投资备选项目-热处理
- EMS特快专递收费标准参考
- 《能者与多劳》议论文阅读试卷讲评
- 人教版小学四年级语文下册期末测试卷答案
- 风水桃花运详解桃花运的风水
- 2020年柴油车国六排放标准将实施
- Linux在操作系统理论教学中的应用研究
- 信号与系统 第八章 陈后金版 习题解答
- 【03】坚果云高级使用技巧
- SIMATIC.S7.S7-1200.可编程控制器系统手册
- 记忆一副扑克牌
- 农村小学英语口语教学的策略(张艳)