使用CSS设置HTML标题属性的样式 [英] Styling HTML Title attribute using CSS
问题描述
我正在尝试使用CSS设置<input type="text">
的title属性的样式.这就是我所做的:
I am trying to style the title attribute of a <input type="text">
using CSS. So this is what I did:
input[type="text"][title] {
font-style: italic;
color: gray;
}
可以,但是当我在字段中输入数据时,数据为灰色和斜体.我希望数据(值)是正常的黑色,而标题仅是斜体和灰色.
It works okay, but when I enter data into the field, the data is gray and italic. I want the data (value) to be normal and black, and only the title to be italic and gray.
有什么想法吗?
推荐答案
您可以使用CSS3做自定义解决方案.
You can do a custom solution using CSS3.
看看如何更改锚标记中Title属性的样式?.但是我是否建议您使用数据标题"之类的自定义字段,以使默认浏览器行为不会干扰您的自定义解决方案.
Take a look at How to change the style of Title attribute inside the anchor tag?. But might I suggest that you use a custom field like 'data-title' so the default browser behaviour doesn't interfere with your custom solution.
这篇关于使用CSS设置HTML标题属性的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!