|
/*actually (spoiler alert!) absolute centering |
|
only requires a declared height* |
|
and these styles:*/ |
|
.Center-Container { |
|
position: relative; |
|
} |
|
.Absolute-Center { |
|
margin: auto; |
|
position: absolute; |
|
top: 0; left: 0; bottom: 0; right: 0; |
|
} |
|
/*Advantages: |
|
Cross-browser (including IE8-10) |
|
No special markup, minimal styles |
|
Responsive with percentages and min-/max- |
|
Use one class to center any content |
|
Centered regardless of padding (without box-sizing!) |
|
Blocks can easily be resized |
|
Works great on images |
|
|
|
Caveats: |
|
Height must be declared (see Variable Height) |
|
Recommend setting overflow: auto to prevent content spillover (see Overflow) |
|
Doesn't work on Windows Phone*/ |
|
|
|
/*Модальное окно*/ |
|
|
|
.Absolute-Center.is-Variable { |
|
display: table; /*Если не задана высота очевидно*/ |
|
height: auto; |
|
} |
|
|
|
/*Это не всегда работает, но можно проверить Modernizr |
|
|
|
Caveats: |
|
This will break cross-browser compatibility. You may want |
|
to consider an alternate technique if the Modernizr |
|
test doesn't meet your needs. |
|
• Not compatible with the Resizing technique. |
|
• Firefox/IE8: Using display: table aligns the |
|
content block to the top, but is still centered horizontally. |
|
• IE9/10: Using display: table aligns the content |
|
block to the top left. |
|
• Mobile Safari: The content block is centered |
|
vertically, but becomes slightly off-center |
|
horizontally when using percentage based widths. Тогда так: |
|
*/ |
|
|
|
.absolutecentercontent .Absolute-Center.is-Variable { |
|
display: table; |
|
height: auto; |
|
} |
|
|
|
|
|
|
|
|
|
/*Прибивание по сторонам*/ |
|
.Absolute-Center.is-Right { |
|
left: auto; right: 20px; |
|
text-align: right; |
|
} |
|
|
|
.Absolute-Center.is-Left { |
|
right: auto; left: 20px; |
|
text-align: left; |
|
} |