简体   繁体   English

带有等宽字体的 html 输入中不显示下划线字符

[英]Underscore character not show in html input with font monospace

In Google Chrome the underscore character "_" is not shown in an input control with font-family monospace.在 Google Chrome 中,下划线字符“_”未显示在具有字体系列等宽字体的输入控件中。 Any idea why?知道为什么吗?

Any suggestions for a workaround?任何解决方法的建议?

Demo here演示在这里

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<input type="text" value="test_test">
</body>
</html>
input {
  font-family: monospace;
}

The value in the demo input control is "test_test" but it displays as "test test".演示输入控件中的值为“test_test”,但显示为“test test”。

I'm on Windows 10 and find this problem either.我在 Windows 10 上也发现了这个问题。 The problem occurs on Chrome and Edge (chromium-based), but not Firefox.该问题发生在 Chrome 和 Edge(基于铬)上,但不是 Firefox。 My solution is to unset height property of the input box class.我的解决方案是取消设置输入框类的高度属性。

.form-control {
    height: unset;
}

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

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