HTML CSS Invisible Button

后端 未结 5 1578
星月不相逢
星月不相逢 2020-12-03 05:42

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

相关标签:
5条回答
  • 2020-12-03 05:55

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

    JSFiddle

    0 讨论(0)
  • 2020-12-03 05:59

    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.

    0 讨论(0)
  • 2020-12-03 06:04

    HTML

    <input type="button">
    

    CSS

    input[type=button]{
     background:transparent;
     border:0;
    }
    
    0 讨论(0)
  • 2020-12-03 06:17
    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

    0 讨论(0)
  • 2020-12-03 06:18

    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.

    0 讨论(0)
提交回复
热议问题