Home > Mobile >  How to make a button bigger by hovering it in HTML CSS
How to make a button bigger by hovering it in HTML CSS

Time:09-18

Hello so am looking for how to make a button bigger by hovering it, like alot of professional websites, So I know a very little thing on how to make the transform of it upper by hovering by adding transform translate, but I also want to know how to make it bigger. Note: I don't really want to make it done by making the font size bigger, cause after I got my answer I maybe do it for a div. Also am a bit new to coding, sorry if there is better way to describe my question, any help appreciated!

CodePudding user response:

I think what you are looking for is this CSS snippet

btn:hover{
    transform: scale(2);
}

This article on MDN has a neat tool to see what can be done with the transform property MDN Article

CodePudding user response:

You can use :hover & set property directly now.

'transform' is not a must.

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100%;
}

button {
    padding: 1em;
    background: linear-gradient(60deg, rgb(216, 81, 81), rgb(93, 93, 205));
    color: white;
    font-size: large;
    white-space: nowrap;
}

button:hover {
    scale: 1.25;
    translate: 0 -20px;
}
    <div >
        <button>hover me</button>
    </div>

  • Related