_popover.scss 4.67 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
2
3
4
5
.popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: $zindex-popover;
fat's avatar
fat committed
6
  display: block;
Mark Otto's avatar
Mark Otto committed
7
  max-width: $popover-max-width;
Mark Otto's avatar
Mark Otto committed
8
9
10
11
  // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
  // So reset our font and text properties to avoid inheriting weird values.
  @include reset-text();
  font-size: $font-size-sm;
12
13
  // Allow breaking very long words so they don't overflow the popover's bounds
  word-wrap: break-word;
Mark Otto's avatar
Mark Otto committed
14
15
  background-color: $popover-bg;
  background-clip: padding-box;
16
  border: $popover-border-width solid $popover-border-color;
Mark Otto's avatar
Mark Otto committed
17
  @include border-radius($border-radius-lg);
18
  @include box-shadow($popover-box-shadow);
fat's avatar
fat committed
19

20
21
  // Arrows
  //
22
23
24
25
26
27
28
  // .arrow is outer, .arrow::after is inner

  .arrow {
    position: absolute;
    display: block;
    width: $popover-arrow-width;
    height: $popover-arrow-height;
29
    margin: 0 $border-radius-lg;
30
  }
31
32
33
34
35

  .arrow::before,
  .arrow::after {
    position: absolute;
    display: block;
36
    content: "";
37
38
39
40
    border-color: transparent;
    border-style: solid;
  }

fat's avatar
fat committed
41
42
  // Popover directions

Johann-S's avatar
Johann-S committed
43
  &.bs-popover-top {
44
    margin-bottom: $popover-arrow-height;
fat's avatar
fat committed
45

46
    .arrow {
47
      bottom: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
48
49
    }

50
51
    .arrow::before,
    .arrow::after {
52
      border-width: $popover-arrow-height $popover-arrow-width/2 0;
53
54
    }

55
    .arrow::before {
56
      bottom: 0;
fat's avatar
fat committed
57
      border-top-color: $popover-arrow-outer-color;
58
59
    }

60
    .arrow::after {
61
      bottom: $popover-border-width;
62
      border-top-color: $popover-arrow-color;
fat's avatar
fat committed
63
64
65
    }
  }

Johann-S's avatar
Johann-S committed
66
  &.bs-popover-right {
67
    margin-left: $popover-arrow-height;
fat's avatar
fat committed
68

69
    .arrow {
70
71
72
73
      left: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
      width: $popover-arrow-height;
      height: $popover-arrow-width;
      margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
74
75
    }

76
77
    .arrow::before,
    .arrow::after {
78
      border-width: $popover-arrow-width/2 $popover-arrow-height $popover-arrow-width/2 0;
79
80
    }

81
    .arrow::before {
82
      left: 0;
fat's avatar
fat committed
83
      border-right-color: $popover-arrow-outer-color;
84
85
    }

86
    .arrow::after {
87
      left: $popover-border-width;
88
      border-right-color: $popover-arrow-color;
fat's avatar
fat committed
89
90
91
    }
  }

Johann-S's avatar
Johann-S committed
92
  &.bs-popover-bottom {
93
    margin-top: $popover-arrow-height;
fat's avatar
fat committed
94

95
    .arrow {
96
      top: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
97
98
    }

99
100
    .arrow::before,
    .arrow::after {
101
      border-width: 0 $popover-arrow-width/2 $popover-arrow-height $popover-arrow-width/2;
102
103
    }

104
    .arrow::before {
105
      top: 0;
fat's avatar
fat committed
106
      border-bottom-color: $popover-arrow-outer-color;
107
108
    }

109
    .arrow::after {
110
      top: $popover-border-width;
111
      border-bottom-color: $popover-arrow-color;
112
113
    }

Mark Otto's avatar
Mark Otto committed
114
115
    // This will remove the popover-header's border just below the arrow
    .popover-header::before {
116
117
118
119
      position: absolute;
      top: 0;
      left: 50%;
      display: block;
120
121
      width: $popover-arrow-width;
      margin-left: -$popover-arrow-width/2;
122
      content: "";
123
      border-bottom: $popover-border-width solid $popover-header-bg;
fat's avatar
fat committed
124
125
126
    }
  }

Johann-S's avatar
Johann-S committed
127
  &.bs-popover-left {
128
    margin-right: $popover-arrow-height;
fat's avatar
fat committed
129

130
    .arrow {
131
132
133
134
      right: calc((#{$popover-arrow-height} + #{$popover-border-width}) * -1);
      width: $popover-arrow-height;
      height: $popover-arrow-width;
      margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
135
136
    }

137
138
    .arrow::before,
    .arrow::after {
139
      border-width: $popover-arrow-width/2 0 $popover-arrow-width/2 $popover-arrow-height;
140
141
    }

142
    .arrow::before {
143
      right: 0;
fat's avatar
fat committed
144
      border-left-color: $popover-arrow-outer-color;
145
146
    }

147
    .arrow::after {
148
      right: $popover-border-width;
149
      border-left-color: $popover-arrow-color;
fat's avatar
fat committed
150
    }
151
  }
Johann-S's avatar
Johann-S committed
152
153
154
155
156
157
158
159
160
161
162
163
164
165
  &.bs-popover-auto {
    &[x-placement^="top"] {
      @extend .bs-popover-top;
    }
    &[x-placement^="right"] {
      @extend .bs-popover-right;
    }
    &[x-placement^="bottom"] {
      @extend .bs-popover-bottom;
    }
    &[x-placement^="left"] {
      @extend .bs-popover-left;
    }
  }
Mark Otto's avatar
Mark Otto committed
166
167
}

168

fat's avatar
fat committed
169
// Offset the popover to account for the popover arrow
Mark Otto's avatar
Mark Otto committed
170
171
.popover-header {
  padding: $popover-header-padding-y $popover-header-padding-x;
172
  margin-bottom: 0; // Reset the default from Reboot
Mark Otto's avatar
Mark Otto committed
173
  font-size: $font-size-base;
Mark Otto's avatar
Mark Otto committed
174
175
176
  color: $popover-header-color;
  background-color: $popover-header-bg;
  border-bottom: $popover-border-width solid darken($popover-header-bg, 5%);
177
178
  $offset-border-width: calc(#{$border-radius-lg} - #{$popover-border-width});
  @include border-top-radius($offset-border-width);
179
180
181
182

  &:empty {
    display: none;
  }
Mark Otto's avatar
Mark Otto committed
183
184
}

Mark Otto's avatar
Mark Otto committed
185
186
187
.popover-body {
  padding: $popover-body-padding-y $popover-body-padding-x;
  color: $popover-body-color;
Mark Otto's avatar
Mark Otto committed
188
}