1

I am making an HTML5 video player, but I need to put a play icon on my button and the old method no longer works. Also, I cannot use background-image:url('Filename'); because I also have a gradient, and when I add the background-image it overrides my gradient. Any suggestions?

2 Answers 2

1

you can do what twitter bootstrap does and use an <i class="some-icon-class"></i> in the content to easily add icons.

the CSS for that <i> tag is set to a block with a certain height and width, and has a background image.

they use it like this:

<button ...><i class="plus-icon"></i> Add New Item</button>

check it out: http://getbootstrap.com/2.3.2/base-css.html#icons

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

4 Comments

Where you have "Add New Item", is this where I would put my image tag? But I will definitely try this method.
no, you dont use an image tag at all. you apply a background image to the CSS of the <i> tag itself.
Will this override my gradient?
it shouldn't. twitter bootstrap's buttons have gradients in addition to the actual icon.
0

You have not specified what your button element tag is exactly. But since you say "html5" I will assume you are using the actual "button" tag. Maybe try this:

<button onClick="eventHandler();"><img src="button_image.png" /></button>

Or perhaps you are looking for "more proper" html5 where img tag is not used and all styling is strictly in the CSS?

2 Comments

Yes, an actual button tag. I want to put an image on that and keep my gradient.
Ok, cool. So if putting a nested img tag is ok for you, then use png or gif with transparency for most of the button image. Just put a little icon in the middle and possibly some borders or shadows around the image edges.

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.