Skip to content

Instantly share code, notes, and snippets.

@movii
Last active July 11, 2017 12:22
Show Gist options
  • Save movii/c7477f77f365b921c2463ce3a8c05144 to your computer and use it in GitHub Desktop.
Save movii/c7477f77f365b921c2463ce3a8c05144 to your computer and use it in GitHub Desktop.
笔记:前端开发中的「居中」,绝对定位,transform 和 flex 布局:1. html structure
<!--
HTML 结构:
1. div.box 作为外层居中容器
2. div.content 作为内部居中对象
-->
<div class="box">
<div class="content">
content
</div>
</div>
/* 外层居中容器的公共样式 */
.box {
width: 240px;
height: 300px;
border: 1px solid #f1f1f1;
background-color: #F4F3F0;
margin: 0 auto;
}
/* 内部居中对象的公共样式 */
.box .content {
/* center target */
width: 180px;
height: 100px;
text-align: center;
line-height: 100px;
background-color: #EAE8E3;
border: 1px solid #aaaaaa;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment