Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradient and Image on Form Submit button?

Tags:

html

css

I was wondering if there is a way to have an image on a submit button while preserving the gradient.

Heres the gradient I have and am using.

enter image description here

But I want to add an image as well, like below. But by adding the image it overrides the gradient.

enter image description here

Heres the code I use to add the button.

background-position:  center left;
background-image: url(../images/icons/cross.png);
background-repeat: no-repeat;

Below is photoshoped version of what I want, as you can see both gradient and image are present.

enter image description here

Any ideas? Obviously you can't add an image to a submit button via html? Or can you?

Update

Heres the snippets of the code

Gradient CSS

.whitegrad
{
background:#fefefe;
background: -moz-linear-gradient(top,  #fefefe 0%, #e3e3e3 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#fefefe), color-stop(100%,#e3e3e3));
   /* etc etc */
}

HTML for the form

<form action='' method='post' class='addtofavorites' >
    <input type='hidden' class='atf_video_id' name='atf_video_id' value='' />
    <input class='whitebtn whitegrad rndrgt' type='submit' value='Add to Favorites' />

</form>
like image 368
Sean H Jenkins Avatar asked May 01 '26 16:05

Sean H Jenkins


2 Answers

Why would you use the image of a cross, when you have an actual text version of that available to you?

You could either include the '+' within the button text:

<button type="submit">+ Add to Favourites</button>

Or use CSS-generated content to add it:

<button type="submit">Add to Favourites</button>

button:before {
    content: '+ ';
}

JS Fiddle demo.

like image 99
David Thomas Avatar answered May 03 '26 10:05

David Thomas


The <button> tag lets you put HTML inside of it. You can add onclick + onkeypress event handlers to call submit() on the form. Then, you can keep the background gradient on the <button>.

You can also use multiple backgrounds with CSS3, but it isn't well-supported yet.

like image 29
John Kurlak Avatar answered May 03 '26 09:05

John Kurlak



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!