How to make a transparent HTML button?

后端 未结 6 2080
情歌与酒
情歌与酒 2020-12-23 00:33

I am using dreamweaver to create a website and I thought of just using Photoshop to create backgrounds. I decided to do so only because in case I\'d choose to change the but

相关标签:
6条回答
  • 2020-12-23 00:39

    Make a div and use your image ( png with transparent background ) as the background of the div, then you can apply any text within that div to hover over the button. Something like this:

    <div class="button" onclick="yourbuttonclickfunction();" >
    Your Button Label Here
    </div>
    

    CSS:

    .button {
    height:20px;
    width:40px;
    background: url("yourimage.png");
    }
    
    0 讨论(0)
  • 2020-12-23 00:48

    Setting its background image to none also works:

    button {
        background-image: none;
    }
    
    0 讨论(0)
  • 2020-12-23 00:50

    **add the icon top button like this **

    #copy_btn{
    	align-items: center;
    	position: absolute;
    	width: 30px;
      height: 30px;
         background-color: Transparent;
        background-repeat:no-repeat;
        border: none;
        cursor:pointer;
        overflow: hidden;
        outline:none;
    }
    .icon_copy{
    	position: absolute;
    	padding: 0px;
    	top:0;
    	left: 0;
    width: 25px;
      height: 35px;
      
    }
    <button id="copy_btn">
    
                            <img class="icon_copy" src="./assest/copy.svg" alt="Copy Text">
    </button>

    0 讨论(0)
  • 2020-12-23 00:53

    To get rid of the outline when clicking, add outline:none

    jsFiddle example

    button {
        background-color: Transparent;
        background-repeat:no-repeat;
        border: none;
        cursor:pointer;
        overflow: hidden;
        outline:none;
    }
    

    button {
        background-color: Transparent;
        background-repeat:no-repeat;
        border: none;
        cursor:pointer;
        overflow: hidden;
        outline:none;
    }
    <button>button</button>

    0 讨论(0)
  • 2020-12-23 00:55

    The solution is pretty easy actually:

    <button style="border:1px solid black; background-color: transparent;">Test</button>
    

    This is doing an inline style. You're defining the border to be 1px, solid line, and black in color. The background color is then set to transparent.


    UPDATE

    Seems like your ACTUAL question is how do you prevent the border after clicking on it. That can be resolved with a CSS pseudo selector: :active.

    button {
        border: none;
        background-color: transparent;
        outline: none;
    }
    button:focus {
        border: none;
    }
    

    JSFiddle Demo

    0 讨论(0)
  • 2020-12-23 00:58
    <div class="button_style">
    This is your button value
    </div>
    
    .button_style{   
    background-color: Transparent;
    border: none;             /* Your can add different style/properties of button Here*/
    cursor:pointer;    
    }
    
    0 讨论(0)
提交回复
热议问题