【问题标题】:make html input text field as text-overflow left ellipsis将html输入文本字段设为文本溢出左省略号
【发布时间】:2020-07-26 21:29:44
【问题描述】:

我正在使用 HTML 制作二进制到十进制的计算器。在其中,我通过在不使用键盘的情况下单击按钮来输入 0 和 1,但问题是当输入字段填充 0 和 1 时,下一个输入的文本将被隐藏。所以我想要文本输入字段 text-align right 和 text-overflow left 省略号,如:

[.........01010101110101]

我的代码如下。

<html>
<title>Binary to Decimal</title>
<head>
</head>
<body>
<input id="input" style="text-align:right; text-overflow:ellipsis;" type="text" >
<br>
<br>
<input  onclick="enter(0)" value="0" type="button">
<input onclick="enter(1)" value="1" type="button">
<input onclick="convert()" value="Convert" type="button">
<script>
function enter(n_val){
document.getElementById("input").value += n_val
}
</script>
</body>
</html>

【问题讨论】:

标签: javascript html css overflow ellipsis


【解决方案1】:

#input上设置direction: rtl;

function enter(n_val) {
  document.getElementById("input").value += n_val
}
#input {
  direction: rtl;
  text-overflow:ellipsis;
}
<input id="input" type="text" />
<br/>
<br/>
<input onclick="enter(0)" value="0" type="button">
<input onclick="enter(1)" value="1" type="button">
<input value="Convert" type="button">

【讨论】:

猜你喜欢
  • 2012-04-04
  • 2012-04-05
  • 2011-12-05
  • 1970-01-01
  • 2018-07-22
  • 1970-01-01
相关资源
最近更新 更多