[英]How to position cursor in search field after placeholder
I am using Vue for a small app and I have an input type search.我正在为一个小型应用程序使用 Vue,并且我有一个输入类型搜索。 The problem is that the cursor is displayed in the beginning of the input, but I want it to be displayed after the placeholder text.
问题是 cursor 显示在输入的开头,但我希望它显示在占位符文本之后。 How can I achieve this?
我怎样才能做到这一点?
Here is my code:这是我的代码:
.search { height: 36px; width: 256px; margin-right: 42px; border: 1px solid #76b1c5; box-sizing: border-box; border-radius: 18px; }
<input type="search" name="" id="" class="search" placeholder="search" />
and my CSS:和我的 CSS:
.search {
height: 36px;
width: 256px;
margin-right: 42px;
border: 1px solid #76b1c5;
box-sizing: border-box;
border-radius: 18px;
}
You cannot do this given your current setup.鉴于您当前的设置,您无法执行此操作。
The reason being that the cursor appears at the same place that the placeholder text starts.原因是 cursor 出现在占位符文本开始的同一位置。 So, no matter how you alter the placeholder text, or the cursor, they will always begin at the same place.
因此,无论您如何更改占位符文本或 cursor,它们都将始终从同一位置开始。
If you wish to disconnect the cursor from the placeholder text, then you will need to create separate elements in order to accomplish that.如果您希望将 cursor 与占位符文本断开连接,则需要创建单独的元素才能完成此操作。 For example, using a label, or a div, or a span, or some combination of elements to have the text out of the flow of the document in order for it to be removable and separate from altering the layout.
例如,使用 label、div、span 或某些元素组合使文本脱离文档流,以便将其移除并与更改布局分开。 In addition, this would mean implementing the placeholder logic, or leaving the placeholder in place as a label.
此外,这意味着实现占位符逻辑,或将占位符保留为 label。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.