Placeholder does not fully display for input type number in firefox when using a particular font family

Field

input[type="number"]does not display placeholder text in the latest firefox for a particular font family, for example font-family: 'Open Sans';. Current Version of Firefox Quantum 57.0.2 (64-bit)

Still don't know which font family doesn't have such a problem

Please check the demo link https://codepen.io/anon/pen/zpqzEB

enter image description here

body {
  padding: 2rem;
}

input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  line-height: 40px;
  background: #fafafa;
  border: 1px solid tomato;
  padding: .5rem 1rem;
  font-family: 'Open Sans';
  background-clip: content-box;
  background-color: deepskyblue;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<input type="text" placeholder="Text field" />
<hr>
<input type="number" placeholder="Number field" />
+4
source share
4 answers

This is a property of your border field.

, CodePen, JSBin , StackOverflow, . , CodePen Quantum.

, :

border-box , (w3schools.com).

​​ 40 . 40px , padding-top, padding-bottom . ​​ 40 . ( , ) padding: .5rem 1rem;.

40 . enter image description here

: 40px + + > 40px

, , . , . 40px 40px. border-box.

, Chrome Firefox , Chrome . Chrome 22 , 22 .

enter image description here

+1

, .

:

padding: 0.46rem 1rem;

, , .

.

enter image description here

, , , .

https://codepen.io/anon/pen/qpZPKd

, .


. Line-height .

, , , , !

body {
  padding: 2rem;
}

.Wrap{
  box-sizing: border-box;
  height: 40px;
  border: 1px solid tomato;
  padding: .5rem 1rem;
}
.Wrap input {
  width: 100%;
  height: 100%;
  line-height: 40px;
  border: none;
  font-family: 'Open Sans';
  background-color: deepskyblue;
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<div class="Wrap"><input type="text" placeholder="Text field" /></div>
<hr>
<div class="Wrap"><input type="number" placeholder="Number field" /></div>
Hide result

Codepen https://codepen.io/anon/pen/QaNOdo

+1

For some reason, when I go to the height of your input field something above 40 pixels, it seems to work. Try the following:

input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 41px;
    padding: 0 10px;
    line-height: 40px;
    background: #fafafa;
    border: 1px solid tomato;
    padding: .5rem 1rem;
    font-family: 'Open Sans';

    background-clip:content-box;
    background-color: deepskyblue;
}

I do not understand why this corrects this.

0
source

EDIT

You use PADDING twice in your css input declaration ...

Just delete the first one: padding: 0 10px;

And save: padding: .5rem 1rem;

body{
  padding: 2rem;
}
input {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    line-height: 40px;
    background: #fafafa;
    border: 1px solid tomato;
    padding: .5rem 1rem;
    font-family: 'Open Sans';
    background-clip:content-box;
    background-color: deepskyblue;
}

input[type="number"] {
    
    // line-height: 1.5;
}
<input type="text" placeholder="Text field" />
<hr>
<input type="number" placeholder="Number field" />
Run codeHide result
-1
source

Source: https://habr.com/ru/post/1691042/


All Articles