Css 在按钮中添加图像

Css 在按钮中添加图像,css,Css,我试图制作一个按钮,其文本为“立即购买!”,但我想用它显示小图像。我的图像/购买图标中的图像。请告诉我有什么问题? 我的CSS: #submit { background-color: #ffb94b; background-image: -webkit-gradient(linear, left top, left bottom, from(#fddb6f), to(#ffb94b)); background-image: -webkit-linear-gradien

我试图制作一个按钮,其文本为“立即购买!”,但我想用它显示小图像。我的
图像/购买图标中的图像
。请告诉我有什么问题?
我的CSS

#submit
{       
  background-color: #ffb94b;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#fddb6f), to(#ffb94b));
  background-image: -webkit-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -moz-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -ms-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -o-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: linear-gradient(top, #fddb6f, #ffb94b);

 -moz-border-radius: 3px;
 -webkit-border-radius: 3px;
  border-radius: 3px;

  text-shadow: 0 1px 0 rgba(255,255,255,0.5);

  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
   box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;    

   border-width: 1px;
   border-style: solid;
   border-color: #d69e31 #e3a037 #d5982d #e3a037;

   float: left;
   height: 35px;
   padding: 0;
   width: 120px;
   cursor: pointer;
   font: bold 15px Arial, Helvetica;
   color: #8f5a0a;
}

#submit:hover,#submit:focus
{       
  background-color: #fddb6f;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#ffb94b), to(#fddb6f));
  background-image: -webkit-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -moz-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -ms-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -o-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: linear-gradient(top, #ffb94b, #fddb6f);
}   

#submit:active 
{       
outline: none;

 -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
 -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
 box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
}

#submit::-moz-focus-inner
{
 border: none;
}

#actions a
{
color: #3151A2;    
float: right;
line-height: 35px;
margin-left: 10px;
}

#submit.buy_icon
{
  background-image:url("../images/Buy-icon.png");
  float: left;
}
<input type="submit" value="Buy Now!" id="submit" class="buy_icon"/>
在myHTML中

#submit
{       
  background-color: #ffb94b;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#fddb6f), to(#ffb94b));
  background-image: -webkit-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -moz-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -ms-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: -o-linear-gradient(top, #fddb6f, #ffb94b);
  background-image: linear-gradient(top, #fddb6f, #ffb94b);

 -moz-border-radius: 3px;
 -webkit-border-radius: 3px;
  border-radius: 3px;

  text-shadow: 0 1px 0 rgba(255,255,255,0.5);

  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
   box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;    

   border-width: 1px;
   border-style: solid;
   border-color: #d69e31 #e3a037 #d5982d #e3a037;

   float: left;
   height: 35px;
   padding: 0;
   width: 120px;
   cursor: pointer;
   font: bold 15px Arial, Helvetica;
   color: #8f5a0a;
}

#submit:hover,#submit:focus
{       
  background-color: #fddb6f;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#ffb94b), to(#fddb6f));
  background-image: -webkit-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -moz-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -ms-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: -o-linear-gradient(top, #ffb94b, #fddb6f);
  background-image: linear-gradient(top, #ffb94b, #fddb6f);
}   

#submit:active 
{       
outline: none;

 -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
 -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
 box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
}

#submit::-moz-focus-inner
{
 border: none;
}

#actions a
{
color: #3151A2;    
float: right;
line-height: 35px;
margin-left: 10px;
}

#submit.buy_icon
{
  background-image:url("../images/Buy-icon.png");
  float: left;
}
<input type="submit" value="Buy Now!" id="submit" class="buy_icon"/>


但现在购买按钮是成功来唯一的形象是不随它来。我能做什么?请建议。

看起来您在
背景图像中缺少
引号
,您需要
!重要信息
验证默认行为:

.buy_icon
{
background-image:url('../images/Buy-icon.png')  !important;
width:32px;
height:32px;
border-width: 0;
background-color: transparent;
}

看起来您缺少
背景图像中的
引号
,您需要
!重要信息
验证默认行为:

.buy_icon
{
background-image:url('../images/Buy-icon.png')  !important;
width:32px;
height:32px;
border-width: 0;
background-color: transparent;
}

您为“提交”定义的背景优先于您为“购买”图标定义的背景


加上!在.buy_图标中的背景图像属性之后很重要,它可能有帮助

您为#提交定义的背景优先于您为.buy_图标定义的背景

加上!在.buy_图标中的背景图像属性之后很重要,它可能有助于用于此
\submit.buy_图标

像这样

  #submit.buy_icon
    {
    background-image:url("http://i.stack.imgur.com/nPfZp.jpg?s=32&g=1");
background-position:right 0;
    background-repeat:no-repeat;
height:32px;
border-width: 0;
    text-align:left;
    padding-left:10px;
    }
因为你已经定义了你的
css
#现在提交
css
id
比define更强大

css中的id和类

#submit.buy_icon
------------

用于此
的提交.购买图标

像这样

  #submit.buy_icon
    {
    background-image:url("http://i.stack.imgur.com/nPfZp.jpg?s=32&g=1");
background-position:right 0;
    background-repeat:no-repeat;
height:32px;
border-width: 0;
    text-align:left;
    padding-left:10px;
    }
因为你已经定义了你的
css
#现在提交
css
id
比define更强大

css中的id和类

#submit.buy_icon
------------

用于此背景图像:url(“../images/Buy icon.png”);“您的图像url”中的addurl可能希望检查此项,尝试增加按钮的宽度或增加左/右填充,看看是否有效..检查此背景图像中的更新内容:url(“../images/Buy icon.png”);“您的图像url”中的addurl可能需要检查此项。请尝试增加按钮的宽度或增加左/右填充,看看是否有效。检查我更新的anseri使用它,但同样的情况也会发生。@SomnathKayal-使用!重要的是我使用它,但同样的事情也会发生。@SomnathKayal-使用!重要的是,现在图片出来了,但按钮变小了&变黑了。我想把它放在左边&我加了它,但它没有。看上面的代码。你能给我提琴吗?我不明白!!如果现在比请给我看你的problumNow图像的结果图像,但按钮变小了&黑色。我想把它放在左边&我添加了它,但它没有。看上面的代码。你能给我提琴吗?我不明白!!你想这样做,如果现在比请给我看你的problumI的结果图像得到图像,但它总是浮动权利。如何解决?请检查上面的编辑ate代码。我得到了图像,但它总是正确浮动。如何解决?请检查上面的编辑ate代码。