Last active
January 2, 2016 16:39
-
-
Save wangwen1220/8331551 to your computer and use it in GitHub Desktop.
CSS: 只用 CSS 做到完全居中 | CSS Center
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
| /** 只用 CSS 做到完全居中 **/ | |
| .absolute-center { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| bottom: 0; | |
| right: 0; | |
| width: 50%; | |
| height: 50%; | |
| /*overflow: auto;*/ | |
| margin: auto; | |
| } | |
| /* 容器内对齐 */ | |
| .absolute-center-container { | |
| position: relative; | |
| } | |
| /* 在可视区域内居中 */ | |
| .absolute-center-fixed { | |
| position: fixed; | |
| z-index: 999; | |
| } | |
| /* 带响应式 */ | |
| .absolute-center-responsive { | |
| width: 60%; | |
| height: 60%; | |
| min-width: 200px; | |
| max-width: 400px; | |
| padding: 40px; | |
| } | |
| /* 大小可调整 */ | |
| .absolute-center-resizable { | |
| min-width: 20%; | |
| max-width: 80%; | |
| min-height: 20%; | |
| max-height: 80%; | |
| resize: both; | |
| overflow: auto; | |
| } | |
| /* 图像 */ | |
| .absolute-center-img { | |
| height: auto; | |
| } | |
| .absolute-center-img img { | |
| width: 100%; | |
| height: auto; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment