Skip to content

Instantly share code, notes, and snippets.

@foru17
Created September 10, 2014 09:03
Show Gist options
  • Save foru17/83c023ce654a063fe2c7 to your computer and use it in GitHub Desktop.
Save foru17/83c023ce654a063fe2c7 to your computer and use it in GitHub Desktop.
让百分比的布局元素居中
.wrap{
width:50%;
height:300px;
positon:relative;
}
.center{
position: absolute;
top: 50%;
left: 50%;
width:50%;
height:30%;
padding:20px;
text-align:center;
background:#393;
color:#fff;
transform: translate(-50%, -50%);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment