简体   繁体   English

输入类型按钮时图标内部出现问题

[英]Problems with icon inside input with type button

I have a problem, i have 2 buttons that you can see below. 我有一个问题,我有2个按钮,您可以在下面看到。 I need to add errorIcon but want to maintain the looks in button 1. Button 1 have browser specifik style, i have done nothing to button1. 我需要添加errorIcon但要保持按钮1的外观。按钮1具有浏览器指定的样式,我对button1没有做任何事情。

Firefox中按钮的图片

HTML: HTML:

Button1: <input type="button" value="Button1" />
Button2: <input type="button" class="errorIcon" value="Button2" />

CSS: CSS:

 .errorIcon{
    background: url("errorIcon.png") no-repeat scroll top left;
    padding-left: 10px;
    width: 10px;
 }

Please note that i cant use example below because it triggers something i cant do anything about. 请注意,我无法使用下面的示例,因为它会触发我无法做任何事情。 Something else in the program runs on "button". 程序中的其他内容在“按钮”上运行。 This example gives me Button1 with error img as i want it to be. 本示例为我提供了错误img的Button1,因为它是我想要的。

<button><span class="errorIcon></span></button>

You need to style both buttons cause of you leave first button unstyled it will change look depending on browser and system. 您需要设置两个按钮的样式,因为您将第一个按钮保留为未样式设置,这将取决于浏览器和系统而改变外观。 So style both of them 所以他们两个都造型

You can style button using gradients like this http://www.cssbuttongenerator.com/ 您可以使用类似http://www.cssbuttongenerator.com/的渐变来设置按钮样式

And add image via ::before or ::after 并通过:: before或:: after添加图像

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

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