简体   繁体   English

输入提交按钮的图像背景和文本-CSS

[英]Image background and text for input submit button - CSS

I'm trying to make a button for my form which has an image background and displays the text on top of the background. 我正在尝试为表单设置一个按钮,该按钮具有图像背景并在背景顶部显示文本。 Seems very simple but I'm struggling to get the text to appear no matter what I try and struggling after an hour of searching to find someone with a similar problem so assume I'm doing something stupid!. 看起来很简单,但是无论经过什么小时的努力寻找一个类似问题的人,我都想尽一切努力使文本显示出来,所以假设我做的很蠢!

Here's my CSS: 这是我的CSS:

#detail-left .cart-button {
    background : url("../graphics/cart-button.png");
    border : none;
    color : transparent;
    height: 48px;
    width: 118px;
    padding: 10px;
    line-height: 48px;
}

and my html: 和我的HTML:

<input class='cart-button' type='submit' value='Add' />

Remove color:transparent. 去除颜色:透明。 Its making your text transparent give it some color. 它使您的文本透明,使其具有某种颜色。

Remove color : transparent; 去除color : transparent; from your style class, That should work 从你的风格课,那应该工作

#detail-left .cart-button {
    background : url("../graphics/cart-button.png");
    border : none;
    height: 48px;
    width: 118px;
    padding: 10px;
    line-height: 48px;
}

Try this working fiddle 试试这个工作的小提琴

The "color : transparent;" “颜色:透明;” setting will cause the text to be completely transparent, if you want the text to have half-transparency consider using rgba. 设置将导致文本完全透明,如果您希望文本具有半透明性,请考虑使用rgba。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM