Skip to content

Instantly share code, notes, and snippets.

@GingerBear
Created March 6, 2014 20:19
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/9398770 to your computer and use it in GitHub Desktop.
Save GingerBear/9398770 to your computer and use it in GitHub Desktop.
horizontal centering
/* horizontal centering
method 1; negative margin
h1 {
width: 350px;
position: relative;
left: 50%;
margin-left: -175px;
}*/
/* method2: text align
h1 {
text-align: center;
}*/
/* method 3: margin: 0 auto;
h1 {
width: 350px;
margin: 0 auto;
}*/
/*method 4: flexbox*/
.container {
display: flex;
}
h1 {
margin: auto;
}
<div class="container"><h1>欢迎来学习HTML/CSS</h1></div>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment