惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
Arctic Wolf
T
The Blog of Author Tim Ferriss
月光博客
月光博客
Recent Announcements
Recent Announcements
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 三生石上(FineUI控件)
P
Proofpoint News Feed
The Register - Security
The Register - Security
博客园 - 叶小钗
博客园 - Franky
The Cloudflare Blog
雷峰网
雷峰网
罗磊的独立博客
M
MIT News - Artificial intelligence
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
爱范儿
爱范儿
博客园 - 司徒正美
Recorded Future
Recorded Future
酷 壳 – CoolShell
酷 壳 – CoolShell
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
B
Blog
大猫的无限游戏
大猫的无限游戏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
WordPress大学
WordPress大学
小众软件
小众软件
K
Kaspersky official blog
Attack and Defense Labs
Attack and Defense Labs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Forbes - Security
Forbes - Security
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
The Last Watchdog
The Last Watchdog
N
News and Events Feed by Topic
B
Blog RSS Feed
S
Security @ Cisco Blogs
美团技术团队
量子位
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cloudbric
Cloudbric
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - puexine

解除一些网站利用【user-select: none;】禁止复制的限制! [nginx环境]Typecho安装在根目录与子目录的伪静态规则 Download VMware Workstation Pro css3 box-sizing属性 Google Chrome离线安装包下载 谷歌浏览器下载 Windows Defender Manually download the latest updates 纯CSS实现:垂直居中,未知宽高,已知宽高,IE5除外所有浏览器均兼容 常用公共DNS服务器地址 用户中心 - 博客园 VMWare CentOS 6.5 安装vmware-tools 彻底删除卸载Windows XP自带的Windows Message Windows Media Player Firefox Plugin支持Windows Server 2003的方法 微软软件运行库整理下载 – .NET Framework、VC++库、DirectX等 PIN码PJ教程,reaver 使用方法和技巧 Reaver基本命令参数详解及应用 另辟蹊径,CSS设置垂直居中 css实现固定高度及未知高度文字垂直居中的完美解决方案 显示器驱动程序已停止响应 并且已成功恢复 来自星星的你
使用 inline-block 水平垂直居中任意内容
puexine · 2016-04-11 · via 博客园 - puexine

挺好用的水平垂直居中任意内容代码,并且支持度很高

html

<!-- 注释用于去除 inline-block `间隙` -->
<div class="container"><!--
 --><div class="center">
            <h2>这个是居中标题</h2>
            <p>这里是一些文字,文字</p>
     </div><!--
--></div>

css

.container {
    text-align: center;
    width: 100%;
    height: 300px;
}
.container:before,
.container:after    /* :after 可以不需要 */
{
    display: inline-block;
    vertical-align: middle;
    content: '';
    height: 100%;
}
.center {
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
}

posted @ 2016-04-11 19:49  puexine  阅读(6294)  评论(0)    收藏  举报