CSS: How to have a button background image of the same size as the button?

11,670

Try background-size: cover;, if I'm understanding what you. Good luck!

Share:
11,670
CrazySynthax
Author by

CrazySynthax

Updated on June 04, 2022

Comments

  • CrazySynthax
    CrazySynthax almost 2 years

    I read this link, and unfortunately, it didn't help me: How to make background image shrink proportionally to fit button size in javascript?

    I want to generate a button, whose background will be an image. I want CSS to match the image size to be as big as the button is.

    This is the CSS I wrote:

    button {
        border: solid;
        background-image: url("../img/download.png");
        background-size: 100%;
    }
    

    I don't know why, but I don't see any image in the button background. Do you know how to help me?