I have an input field, and inside it on the right side there is a string that displays information to the user.

我有一个输入字段,在右侧有一个字符串,向用户显示信息。

<div class="my_div_class">
    <input class="my_input_class" type="text" placeholder="Search">
    <span class="my_span_class">6000 available</span>
</div>

Using position relative and absolute, I places the span inside the input field.

使用position relative和absolute,我将span放在输入字段中。

However, if the user types a long query, the text will be under the span text.

但是,如果用户键入长查询,则文本将位于范围文本下。

Is there a way to force the input field to do the horizontal scroll when the user reaches a point before the right margin, ideally without using javascript?

有没有办法强制输入字段在用户到达右边距之前的点时进行水平滚动,理想情况下不使用javascript?

2 个解决方案

#1


1

You can add some padding-right to the input box.

您可以在输入框中添加一些填充权限。

.my_div_class {
  position: relative;
  width: 200px;
}
.my_input_class {
  width: 100%;
  padding-right: 100px;
  box-sizing: border-box;
}
.my_span_class {
  position: absolute;
  right: 0;
  top: 0;
}
<div class="my_div_class">
  <input class="my_input_class" type="text" placeholder="Search">
  <span class="my_span_class">6000 available</span>
</div>

更多相关文章

  1. 用于检查用户名可用性的Javascript帖子无效
  2. 使用jquery和php手动在数据库中增加一个字段[复制]
  3. PHP中对用户密码进行加密
  4. 如何在PHP中自动设置用户的语言环境?
  5. 存储用户所需语言的最佳方式
  6. Pubsub与Node.js和Socket.io为个人用户
  7. 如何使用用户名作为子域名创建子域?
  8. 更新日期字段时为空 - MySQL PHP
  9. jQuery PHP:检查用户名是否已经存在

随机推荐

  1. Android六大优势
  2. Android流媒体
  3. Android布局优化之TextView、ImageView合
  4. Android中native进程内存泄露的调试技巧
  5. 别再问我Android前景如何
  6. android 中一个工程引用另一个工程
  7. Android中网络编程以及与服务器上Web项目
  8. Android(安卓)SDK Manager更新 != 问题
  9. 2011Android技术面试整理附有详细答案(包
  10. Android用户近60%仍使用2.3版本 4.0版本