仅使用CSS移除输入元素的值属性 [英] remove value attribute of input element using CSS only

查看:106
本文介绍了仅使用CSS移除输入元素的值属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < input type =我有一个提交按钮,我试图用图像替换提交value =继续/> 

我无法修改HTML,也无法使用JavaScript。我只能访问CSS。



是否可以删除单词继续( value 属性)只使用CSS?



编辑



实际上,已经有图像的按钮。我现在要删除继续按钮。我已经通过将 text-indent 值设置为负数来完成它,前面曾提到这个值,但是被删除了。我不知道是谁发布了它,所以我可以接受它作为答案。

口味不好,但是使用 em 和<$ c替代 font-size:0 $ c> ex 单元不可能,就是让文本呈现透明的画笔,实际上根本不会渲染它:

  color:transparent; 

请注意,应用于输入元素的上述规则对无效元素中占位符文本的颜色。



这个解决方案仍然有许多可能不受欢迎的特征 - 您可能希望至少添加 user-select:none 以及上面的规则,以禁止用户选择文本,因为选择它会暴露它与选择的纯色背景颜色,这可能是也可能不是理想的。


I have a "Submit" button which I'm trying to replace with an image

<input type="submit" value="Continue" />

I can't modify the HTML, and can't use JavaScript. I only have access to the CSS.

Is it possible to remove the word "Continue" (value attribute) using CSS only?

EDIT

I've actually been able to style the button with the image already. I now want to remove the "Continue" button. I've done it by setting the text-indent value to negative, which was suggested here a while ago, but was deleted. I wonder who posted it so I could accept it as the answer.

解决方案

I haven't found anything that doesn't leave a bad taste in my mouth, but an alternative to font-size: 0 which makes using em and ex units for the element impossible, is to make the text render with transparent "brush", effectively not rendering it at all:

color: transparent;

Note that the above rule applied to an input element has no effect on the color of the placeholder text in the element.

There is still a number of potentially undesirable traits to this solution -- you would probably want to at least add user-select: none along with the above rule, to disable user selection of text, because selecting it would expose it against the solid background color of the selection, which may or may not be desirable.

这篇关于仅使用CSS移除输入元素的值属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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