【问题标题】:Why does Safari & Firefox cut off bottom of input text?为什么 Safari 和 Firefox 会切断输入文本的底部?
【发布时间】:2016-11-25 14:30:22
【问题描述】:

我想要什么

在 Chrome 上,输入文本看起来很正常。

发生了什么

火狐

Safari

如您所见,输入文本在 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>

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;
}

JSFiddle

【问题讨论】:

    标签: html css firefox safari


    【解决方案1】:

    有些人提出的解决方案有时不适用于占位符,这里有更强大的方法:

    input::placeholder {
      overflow: visible;
    }
    

    【讨论】:

      【解决方案2】:

      input 上使用line-height:1 修复了此问题

      【讨论】:

        【解决方案3】:

        原因是将 line-height 放在占位符上,如果删除它,它将不再被剪切

        【讨论】:

        • 对我有用。必须给它 line-height:160%;谢谢!!
        【解决方案4】:

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

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

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

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

        【讨论】:

          猜你喜欢
          • 2019-03-10
          • 2015-10-29
          • 1970-01-01
          • 2011-11-12
          • 2012-05-13
          • 2012-04-11
          • 2017-10-06
          • 1970-01-01
          • 2014-12-08
          相关资源
          最近更新 更多