为占位符中的文本样式部分 [英] Styling part of the text in the placeholder

查看:166
本文介绍了为占位符中的文本样式部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改占位符部分的CSS样式。注意不是所有占位符

如果我的预留位置为:Where(example:New York)

If my placeholder is: "Where (example: New York)"

<label>Search:</label>
<textarea placeholder="Where (example: New York)" required="required">
</textarea>

只能设置为斜体(例如:纽约)

对于所有占位符外观,此处

For all the placeholder look here

推荐答案

您可能想考虑占位符的作用和含义。大多数UI专家同意:占位符是标签。标签(如搜索)是标签,应在文本区域之外。占位符设计为样本输入,格式,不是标签,也不是指令。在您以类似标签的方式使用占位符的情况下,该信息将在用户开始输入时立即消失。

You may want to think about what the role and meaning of placeholders is. Most UI experts agree: placeholders are not labels. Labels (like "Search") are labels, and should be outside the text area. The placeholder is designed to be a sample input, or a format, not a label, nor instructions. To the extent that you use the placeholder in label-like fashion, that information will disappear as soon as the user starts typing.

例如,在输入字段中电话号码,标签将是电话号码,并且占位符可以是212-555-1234。在你的情况下,搜索应该是标签,棕色狐狸的占位符。如果你想让整个占位符的斜体(但为什么?),你可以做足够容易与占位符伪元素。

For instance, in an input field for a phone number, the label would be "Phone Number", and the placeholder might be "212-555-1234". In your case, "Search" should be the label, and "brown fox" the placeholder. If you want to make that entire placeholder italics (but why?), you can do that easily enough with the placeholder pseudo-elements.

这篇关于为占位符中的文本样式部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆