Skip to content

Commit

Permalink
fix(input): fix input/placeholder alignment on safari (#6072)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba authored and tinayuangao committed Jul 31, 2017
1 parent d9e6f75 commit 9ac5d13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/input/_input-theme.scss
Expand Up @@ -143,11 +143,11 @@
// we need to divide by the scale factor to make it half of the original text size. We again need
// to subtract off the line spacing since the mocks measure to the edge of the text, not the edge
// of the line.
$subscript-margin-top: 0.5em / $subscript-font-scale - $line-spacing;
$subscript-margin-top: 0.5em / $subscript-font-scale - ($line-spacing * 2);
// The padding applied to the input-wrapper to reserve space for the subscript, since it's
// absolutely positioned. This is a combination of the subscript's margin and line-height, but we
// need to multiply by the subscript font scale factor since the wrapper has a larger font size.
$wrapper-padding-bottom: 0.5em + ($line-height * $subscript-font-scale);
$wrapper-padding-bottom: ($subscript-margin-top + $line-height) * $subscript-font-scale;

.mat-input-container {
font-family: mat-font-family($config);
Expand Down Expand Up @@ -193,6 +193,12 @@
}
}

// <input> elements seem to have their height set slightly too large on Safari causing the text to
// be misaligned w.r.t. the placeholder. Adding this margin corrects it.
input.mat-input-element {
margin-top: -$line-spacing * 1em;
}

.mat-input-placeholder-wrapper {
top: -$infix-margin-top;
padding-top: $infix-margin-top;
Expand Down
1 change: 1 addition & 0 deletions src/lib/input/input-container.scss
Expand Up @@ -77,6 +77,7 @@ $mat-input-underline-height: 1px !default;
border: none;
outline: none;
padding: 0;
margin: 0;
width: 100%;

// Prevent textareas from being resized outside the container.
Expand Down

0 comments on commit 9ac5d13

Please sign in to comment.