_overlay.scss 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // We want overlays to always appear over user content, so set a baseline
  2. // very high z-index for the overlay container, which is where we create the new
  3. // stacking context for all overlays.
  4. $cdk-z-index-overlay-container: 1000 !default;
  5. $cdk-z-index-overlay: 1000 !default;
  6. $cdk-z-index-overlay-backdrop: 1000 !default;
  7. // Background color for all of the backdrops
  8. $cdk-overlay-dark-backdrop-background: rgba(0, 0, 0, 0.32) !default;
  9. // Default backdrop animation is based on the Material Design swift-ease-out.
  10. $backdrop-animation-duration: 400ms !default;
  11. $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
  12. @mixin cdk-overlay() {
  13. .cdk-overlay-container, .cdk-global-overlay-wrapper {
  14. // Disable events from being captured on the overlay container.
  15. pointer-events: none;
  16. // The container should be the size of the viewport.
  17. top: 0;
  18. left: 0;
  19. height: 100%;
  20. width: 100%;
  21. }
  22. // The overlay-container is an invisible element which contains all individual overlays.
  23. .cdk-overlay-container {
  24. position: fixed;
  25. z-index: $cdk-z-index-overlay-container;
  26. &:empty {
  27. // Hide the element when it doesn't have any child nodes. This doesn't
  28. // include overlays that have been detached, rather than disposed.
  29. display: none;
  30. }
  31. }
  32. // We use an extra wrapper element in order to use make the overlay itself a flex item.
  33. // This makes centering the overlay easy without running into the subpixel rendering
  34. // problems tied to using `transform` and without interfering with the other position
  35. // strategies.
  36. .cdk-global-overlay-wrapper {
  37. display: flex;
  38. position: absolute;
  39. z-index: $cdk-z-index-overlay;
  40. }
  41. // A single overlay pane.
  42. .cdk-overlay-pane {
  43. // Note: it's important for this one to start off `absolute`,
  44. // in order for us to be able to measure it correctly.
  45. position: absolute;
  46. pointer-events: auto;
  47. box-sizing: border-box;
  48. z-index: $cdk-z-index-overlay;
  49. // For connected-position overlays, we set `display: flex` in
  50. // order to force `max-width` and `max-height` to take effect.
  51. display: flex;
  52. max-width: 100%;
  53. max-height: 100%;
  54. }
  55. .cdk-overlay-backdrop {
  56. // TODO(jelbourn): reuse sidenav fullscreen mixin.
  57. position: absolute;
  58. top: 0;
  59. bottom: 0;
  60. left: 0;
  61. right: 0;
  62. z-index: $cdk-z-index-overlay-backdrop;
  63. pointer-events: auto;
  64. -webkit-tap-highlight-color: transparent;
  65. transition: opacity $backdrop-animation-duration $backdrop-animation-timing-function;
  66. opacity: 0;
  67. &.cdk-overlay-backdrop-showing {
  68. opacity: 1;
  69. // In high contrast mode the rgba background will become solid so we need to fall back
  70. // to making it opaque using `opacity`. Note that we can't use the `cdk-high-contrast`
  71. // mixin, because we can't normalize the import path to the _a11y.scss both for the
  72. // source and when this file is distributed. See #10908.
  73. @media screen and (-ms-high-contrast: active) {
  74. opacity: 0.6;
  75. }
  76. }
  77. }
  78. .cdk-overlay-dark-backdrop {
  79. background: $cdk-overlay-dark-backdrop-background;
  80. }
  81. .cdk-overlay-transparent-backdrop {
  82. // Note: as of Firefox 57, having the backdrop be `background: none` will prevent it from
  83. // capturing the user's mouse scroll events. Since we also can't use something like
  84. // `rgba(0, 0, 0, 0)`, we work around the inconsistency by not setting the background at
  85. // all and using `opacity` to make the element transparent.
  86. &, &.cdk-overlay-backdrop-showing {
  87. opacity: 0;
  88. }
  89. }
  90. // Overlay parent element used with the connected position strategy. Used to constrain the
  91. // overlay element's size to fit within the viewport.
  92. .cdk-overlay-connected-position-bounding-box {
  93. position: absolute;
  94. z-index: $cdk-z-index-overlay;
  95. // We use `display: flex` on this element exclusively for centering connected overlays.
  96. // When *not* centering, a top/left/bottom/right will be set which overrides the normal
  97. // flex layout.
  98. display: flex;
  99. // We use the `column` direction here to avoid some flexbox issues in Edge
  100. // when using the "grow after open" options.
  101. flex-direction: column;
  102. // Add some dimensions so the element has an `innerText` which some people depend on in tests.
  103. min-width: 1px;
  104. min-height: 1px;
  105. }
  106. // Used when disabling global scrolling.
  107. .cdk-global-scrollblock {
  108. position: fixed;
  109. // Necessary for the content not to lose its width. Note that we're using 100%, instead of
  110. // 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width
  111. // that the element had before we made it `fixed`.
  112. width: 100%;
  113. // Note: this will always add a scrollbar to whatever element it is on, which can
  114. // potentially result in double scrollbars. It shouldn't be an issue, because we won't
  115. // block scrolling on a page that doesn't have a scrollbar in the first place.
  116. overflow-y: scroll;
  117. }
  118. }