为什么 Safari 和 Firefox 会切断输入文本的底部?

14w*_*wml 7 html css safari firefox

我想要的是

铬合金 在此处输入图片说明 在 Chrome 上,输入文本看起来很正常。

怎么了

火狐 在此处输入图片说明

苹果浏览器 在此处输入图片说明

如您所见,输入文本在 Firefox 的底部被略微切断,而在 Safari 上则主要被切断。我该如何解决?

如果有人可以对此提供帮助,将不胜感激!

代码

HTML

        <div class="row page-header">
            <div class="col-xs-10">
                <div class="form-group">
                    <input type="text" name="Worksheet-Name" class="form-control input-lg" placeholder="Worksheet Name..." aria-label="Write worksheet name here"> </div>
            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

CSS

/*Add borders when hover or click on input boxes*/
input[type="text"] {
    outline: none;
    box-shadow:none !important;
    border: 1px solid white; /*make the borders invisble by turning same color as background*/
}

input[type="text"]:hover, input[type="text"]:focus{
    border: 1px solid #cccccc;
    border-radius: 8px;
}

/*Style input text boxes*/
input[type='text'][name='Worksheet-Name']{
    font-size: 36px;
    margin-top: 20px;
    margin-left: 15px;
}

input[type='text'][name='Worksheet-Problem']{
    font-size: 20px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Name']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 500; 
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-moz-placeholder { /* Firefox 18- */
    font-weight: 500;
    font-size: 36px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Problem']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 400; 
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-moz-placeholder { /* Firefox 18- */
    font-weight: 400;
    font-size: 20px;
}
Run Code Online (Sandbox Code Playgroud)

JSFiddle

小智 10

伙计们有时提出的解决方案不适用于占位符,这是更强大的方法:

input::placeholder {
  overflow: visible;
}
Run Code Online (Sandbox Code Playgroud)


小智 5

您可以减少底部填充和/或字体大小,这将解决您的溢出问题。

input[type='text'][name='Worksheet-Name']{
    font-size: 35px;//instead of 36
    margin-top: 20px;
    margin-left: 15px;
}
Run Code Online (Sandbox Code Playgroud)

或者

.input-lg {
    height: 46px;
    padding: 10px 16px 0;//change here to have 0
    font-size: 18px;
    line-height: 1.33333;
    border-radius: 6px;
}
Run Code Online (Sandbox Code Playgroud)

也可能在这里用 line-height 回答: Why is Firefox cut off the text in my <input type="text"/>?


小智 5

修复了这个line-height:1问题input