2

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/

4 Answers 4

9

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I saw that, do you know any character like scissors? Thanks!
&#9988; is ✄ -- don't know how well that dingbat is supported font-wise, it's a fairly high number. You may just have to add an <img> to it.
1

You have to use background: url(...) instead of background-image

Comments

1

The linear gradient will be overridden by your background-image once you fix the background-image property.

Best way to do this is to create a div and use linear-gradient on it. Create 2 child elements one which will contain text and other which will contain the icon as background. Make the div behave like a submit button using jquery.

Comments

0

in your .clipboard class remove -image and make it

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

}

because 'no-repeat' is value of background-repeat and and 'right center' is value of background-position, and you are using these values in background-image .

so syntex is background: image-src repeat-value image-position

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.