Created
March 6, 2014 20:19
-
-
Save GingerBear/9398770 to your computer and use it in GitHub Desktop.
horizontal centering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"><h1>欢迎来学习HTML/CSS</h1></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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