简体   繁体   English

HTML输入溢出添加了填充(Firefox)

[英]HTML Input overflow adds padding (Firefox)

EDIT: Added Picture showing the left "padding" 编辑: 添加图片显示左侧的“填充”

I am using HTML Input Element and also a Numeric Input Element. 我正在使用HTML输入元素和数字输入元素。 On both elements. 在两个要素上。

When the number of chars is longer than the Input Element size and you are moving your cursor to the last entered char there is some magic "padding" added in the beginning of the Input Element. 当字符数大于输入元素的大小并且将光标移动到最后输入的字符时,在输入元素的开头添加了一些魔术“填充”。

Is there any way to prevent this behavior? 有什么办法可以防止这种行为?

Example: 例:

 input{ width:5em; } input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } 
 <input type="text" value="000"><br> <input type="text" value="000000000"><br> <input type="number" value="000"><br> <input type="number" value="000000000"><br> 

Note 注意

I'm using additionally a grid as background, but the grid won't fit if padding of the Element is changing. 我另外使用网格作为背景,但是如果Element的填充发生变化,则网格将不适合。

If I understood you right and you need to remove padding influence on your html blocks, you need to use 如果我理解的正确,并且您需要消除对HTML块的填充影响,则需要使用

*{
   box-sizing: border-box;
 }

Or apply this rule to needed block. 或将此规则应用于所需的块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM