Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Background-image not showing

What am I doing bad?

CSS:

.submit{
padding-left:10px;
margin:0;
border:0;
outline: 0;
height:32px;
padding-right:32px;
}
.green-btn {
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#61A801), to(#8CC400));
background: -webkit-linear-gradient(top, #8CC400, #61A801);
background: -moz-linear-gradient(top, #8CC400, #61A801);
background: -ms-linear-gradient(top, #8CC400, #61A801);
background: -o-linear-gradient(top, #8CC400, #61A801);
color: #fff;
font-family: verdana;
font-size: 13px;
font-weight: normal;
border-radius:5px;
}
.clipboard{
background-image: url(http://cdn1.iconfinder.com/data/icons/opensourceicons/32/Scissors.png) no-repeat right center;
}
​

HTML:

<input type="submit" value="Copy" class="submit green-btn clipboard">​

JSFiddle: http://jsfiddle.net/77NYA/

like image 965
Luis Avatar asked Mar 14 '26 04:03

Luis


1 Answers

You cannot specify the position and repeat values inside the background-image property. You can only specify the URL to the image. You'll have to separate them out like this:

.clipboard {
    background-image: url(http://cdn1.iconfinder.com/data/icons/opensourceicons/32/Scissors.png);
    background-repeat: no-repeat;
    background-position: right center;
}

Also note: Some browsers (I don't know which ones) don't allow gradients and background images to be combined together.


Here's an alternate solution using a <button> with an <img> inside it:

<button type="submit" value="Copy" class="submit green-btn">
    <img src="http://cdn1.iconfinder.com/data/icons/opensourceicons/32/Scissors.png" alt="[scissors]" />
    Copy
</button>​
.submit{
padding-left:10px;
margin:0;
border:0;
outline: 0;
height:32px;
line-height:32px;
padding-right:10px;
}
.green-btn {
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#61A801), to(#8CC400));
background: -webkit-linear-gradient(top, #8CC400, #61A801);
background: -moz-linear-gradient(top, #8CC400, #61A801);
background: -ms-linear-gradient(top, #8CC400, #61A801);
background: -o-linear-gradient(top, #8CC400, #61A801);
color: #fff;
font-family: verdana;
font-size: 13px;
font-weight: normal;
border-radius:5px;
}
.green-btn img {
float: right;
margin-left: 10px;
}​

And the jsFiddle preview. Feel free to play with the margins and stuff to make it look more how you want.

like image 165
animuson Avatar answered Mar 17 '26 08:03

animuson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!