有没有可能做这样的事情:
.input[type=number] {
width: (width of the number inside of the input field)
}
最佳答案
用css做不到,用js实现很容易;
例如:
const input = document.querySelector('.myInput');
input.addEventListener('input', () => {
const inputNumber = input.value;
input.style.width = `${inputNumber}%`;
})
<input type="number" min="1" max="100" value="1" class="myInput" />
关于html - 是否可以使输入类型数字适合其显示的数字宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58625454/