Skip to content

Instantly share code, notes, and snippets.

@GingerBear
Forked from anonymous/dabblet.html
Created March 6, 2014 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GingerBear/9399106 to your computer and use it in GitHub Desktop.
Save GingerBear/9399106 to your computer and use it in GitHub Desktop.
vertical and horizontal centering
/* vertical and horizontal centering
method 1: absolute position + negative margin
h1 {
position: absolute;
width: 350px;
height: 50px;
left: 50%;
top: 50%;
margin-left: -175px;
margin-top: -25px;
}*/
/*method 2: flexbox*/
h1{
display: flex;
flex-flow:row nowr
ap;
justify-content: center;
align-items: center;
height: 200px;
}
<div class="container"><h1>欢迎来学习HTML/CSS</h1></div>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment