1

I want to add a button which looks like an image that I will assign but its type would not be "image". For example:

<input type="button" someimagetag="someimagelink" />

Not like

<input type="image" src="" />

How do I do that?

2
  • Why not just use a button element: <button><img src="path/to/image.png" /></button>? Commented Jan 3, 2012 at 23:40
  • Well, I tried what you said but it does not look in harmony with my image. Also, I'm trying to run a js method when the button is clicked and when it is clicked, it supposed to run in the background. Instead, it posts data by loading the action page. Commented Jan 3, 2012 at 23:49

1 Answer 1

1

You could style it as you would with any other element, using CSS.

Look at Twitter's Bootstrap http://twitter.github.com/bootstrap/ any element that uses the 'btn' class will use these styles:

.btn {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    -moz-transition: all 0.1s linear 0s;
    background-color: #E6E6E6;
    background-image: -moz-linear-gradient(center top , #FFFFFF, #FFFFFF 25%, #E6E6E6);
    background-repeat: no-repeat;
    border-color: #CCCCCC #CCCCCC #BBBBBB;
    border-radius: 4px 4px 4px 4px;
    border-style: solid;
    border-width: 1px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #333333;
    cursor: pointer;
    display: inline-block;
    font-size: 13px;
    line-height: normal;
    padding: 5px 14px 6px;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
}

Keep in mind they use CSS3 declarations to style their elements but you could use a background image just as well.

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

2 Comments

It worked by using a background image. Change the style to this: background: transparent url(imgpath.jpg) no-repeat center top; For exact match with the image, width and height are needed to be set.
glad to hear it worked, would you mind setting my answer as the appropriate one?

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.