Skip to content

Commit b541f09

Browse files
authored
fix(select): fix style for ie and firefox (#1916)
1 parent 4433fc9 commit b541f09

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/demo-app/select/select-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="demo-select">
22
<md-card>
3-
<md-select placeholder="Food" [formControl]="foodControl">
3+
<md-select placeholder="Food i would like to eat" [formControl]="foodControl">
44
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }} </md-option>
55
</md-select>
66
<p> Value: {{ foodControl.value }} </p>

src/lib/select/select.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
$md-select-trigger-height: 30px !default;
55
$md-select-trigger-min-width: 112px !default;
66
$md-select-arrow-size: 5px !default;
7+
$md-select-arrow-margin: 4px !default;
78

89
md-select {
910
display: inline-block;
@@ -17,6 +18,7 @@ md-select {
1718
height: $md-select-trigger-height;
1819
min-width: $md-select-trigger-min-width;
1920
cursor: pointer;
21+
position: relative;
2022

2123
[aria-disabled='true'] & {
2224
@include md-control-disabled-underline();
@@ -43,6 +45,24 @@ md-select {
4345

4446
.md-select-value {
4547
position: absolute;
48+
49+
// Firefox and some versions of IE incorrectly keep absolutely
50+
// positioned children of flex containers in the flex flow when calculating
51+
// position. This has been fixed for Firefox 52, slated for early 2017.
52+
// Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=874718
53+
//
54+
// In the meantime, we must adjust the left position to 0 to mimic where it
55+
// would be if it were correctly taken out of the flex flow. It's also necessary
56+
// to adjust the top value because absolutely positioned elements should not be
57+
// affected by the flex container's "align-items" property either. To center the text,
58+
// we must offset by 6px (6px top + 6px bottom + 18px text height = 30px total height).
59+
left: 0;
60+
top: 6px;
61+
62+
[dir='rtl'] & {
63+
left: auto;
64+
right: 0;
65+
}
4666
}
4767

4868
.md-select-arrow {
@@ -51,6 +71,7 @@ md-select {
5171
border-left: $md-select-arrow-size solid transparent;
5272
border-right: $md-select-arrow-size solid transparent;
5373
border-top: $md-select-arrow-size solid;
74+
margin: 0 $md-select-arrow-margin;
5475
}
5576

5677
.md-select-panel {

0 commit comments

Comments
 (0)