21

Hello I am trying to make an invisible button (still functional and clickable), because my buttons styles are embedded in the background and I don't want to slice them, and do it all from beginning.

So I just want to make a button, put it on the part of the background where the button should be and make it invisible so the background button image can be seen and clicked.

Any suggestions? Thank you very much!

Daniele B
  • 3,117
  • 2
  • 23
  • 46
user1880779
  • 2,038
  • 8
  • 30
  • 40

5 Answers5

40

you must use the following properties for a button element to make it transparent.

Transparent Button With No Text

button {

    background: transparent;
    border: none !important;
    font-size:0;
}

Transparent Button With Visible Text

button {

    background: transparent;
    border: none !important;
}​

and use absolute position to position the element.

For Example

you have the button element under a div. Use position : relative on div and position: absolute on the button to position it within the div.

here is a working JSFiddle

here is an updated JSFiddle that displays only text from the button.

Community
  • 1
  • 1
Amyth
  • 32,527
  • 26
  • 93
  • 135
  • thanks, is there anyway to hide everything (while its clickable) but still display the button text only? – user1880779 Dec 21 '12 at 13:49
  • if you want to see the button text, just remove the `font-size:0;` from the above code. see updated answer. – Amyth Dec 21 '12 at 13:51
12

You can use CSS to hide the button.

button {
  visibility: hidden;
}

If your <button> is just a clickable area on the image, why bother make it a button? You can use <map> element instead.

xiaoyi
  • 6,641
  • 1
  • 34
  • 51
8
button {
    background:transparent;
    border:none;
    outline:none;
    display:block;
    height:200px;
    width:200px;
    cursor:pointer;
}

Give the height and width with respect to the image in the background.This removes the borders and color of a button.You might also need to position it absolute so you can correctly place it where you need.I cant help you further without posting you code

To make it truly invisible you have to set outline:none; otherwise there would be a blue outline in some browsers and you have to set display:block if you need to click it and set dimensions to it

Mevin Babu
  • 2,405
  • 21
  • 34
  • thanks, is there anyway to hide everything (while its clickable) but still display the button text only? – user1880779 Dec 21 '12 at 13:44
  • To make the button completely invisible, I set "cursor" to be default, so even when hovering over the button's location, the cursor will never change to a hand. This was exactly the direction I needed - thanks! – Isxek Nov 15 '13 at 00:31
3

HTML

<input type="button">

CSS

input[type=button]{
 background:transparent;
 border:0;
}
Muhammad Usman
  • 10,426
  • 22
  • 72
  • 107
1

Use CSS background:transparent; to your button/div.

JSFiddle

Vucko
  • 20,555
  • 10
  • 56
  • 107