一、css垂直居中
1.line-height(适用于单行文本居中)
eg: html:<p class="wordp">123</p>-
css: .wordp{width:100px;line-height:50px;background:yellow;color:#fff}
2.:befor+inline-block(多对象的垂直居中技巧)
eg:html <h2>123</h2>
<div class="box3">
<div class="content">
立马来看Amos实际完成的 <a href="http://csscoke.com/2015/07/31/nth-child_rwd_album/">CSS3精美相册效果 </a>效果吧!別忘了拖拉一下窗口看看 RWD 效果喔!
</div>
</div>
css:
.box3{
width: 500px;
height: 250px;
border: 1px solid #f00;
margin: auto;
text-align: center;
}
.box3::before{
content:'';
display: inline-block;
height: 100%;
width: 0;
vertical-align: middle;
}
.box3 .content{
width: 400px;
background: #ccc;
display: inline-block;
vertical-align: middle;
}
继续阅读与本文标签相同的文章
上一篇 :
云栖大会调研问卷填写获奖信息公示
下一篇 :
解决vue 引入子组件报错的问题
-
Cassandra gossip介绍系列之一
2026-05-18栏目: 教程
-
GO学习笔记 - 数据校验
2026-05-18栏目: 教程
-
源码分析 RocketMQ DLedger 多副本之 Leader 选主
2026-05-18栏目: 教程
-
源码分析 RocketMQ DLedger 多副本存储实现
2026-05-18栏目: 教程
-
阿里巴巴小程序繁星计划技术能力支持指南
2026-05-18栏目: 教程
