Skip to content

Instantly share code, notes, and snippets.

@hacke2
Last active August 29, 2015 14:06
Show Gist options
  • Save hacke2/f5ec5cbbfc6bfb7bfa92 to your computer and use it in GitHub Desktop.
Save hacke2/f5ec5cbbfc6bfb7bfa92 to your computer and use it in GitHub Desktop.
IE8以上css居中
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
/*CSS3*/
.wrapper {
padding: 20px;
background:orange;
color:#fff;
position:absolute;
top:50%;
left:50%;
border-radius: 5px;
-webkit-transform:translate(-50%,-50%);
-moz-transform:translate(-50%,-50%);
transform:translate(-50%,-50%);
}
/*CSS3另一种方法*/
parent:before { content:'';display:inline-block;vertical-align:middle;height:100%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment