Created
November 3, 2016 02:18
-
-
Save wuliupo/1ed5eeccc7aefbf4303fc5c87adcd6c9 to your computer and use it in GitHub Desktop.
CSS percentage of margin & padding
This file contains hidden or 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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>CSS margin percentage</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | |
| <style> | |
| .container{margin:20px auto;padding:20px;width:600px;height:200px;border:1px solid #CCC;} | |
| .inner{height:50%;background-color:#F90;margin-top:10%;padding:10%;margin-left:10%;} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="inner"> | |
| CSS 中,margin-top | margin-bottom | padding-top | padding-bottom 的百分比值参照的不是容器的高度,而是宽度,宽度,宽度!!!是他自己的宽度~ | |
| 无论垂直还是水平,百分比值始终参考宽度。 | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment