frostzt
frostzt

Reputation: 419

Why is the transform property not working

So I know that two transforms don't apply at the same time. But at hover, they can replace each other?! Following is the code for a button I am trying to make, but when I hover, the properties don't seem to work! Also, the down-arrow I am trying to insert in there is also not exactly at the center. So due to which I have to use padding to center it!

    .btn__bg {
        position: absolute;
        display: inline-block;
        opacity: 0;
        top: 75%;
        left: 50%;
        transform: translate(-50%, -50%);
        height: 60px;
        width: 60px;
        background-color: #000;
        border-radius: 50%;
        text-align: center;
        animation: fadeInTop 1.2s forwards ease-out 1.5s;
        transition: all .2s;
        box-shadow: 0 4px 40px rgba(0,0,0,.3);
    }

    .btn__content {
        font-size: 30px;
        color: #fff;
        font-weight: 100;
        text-decoration: none;
        line-height: normal;
    }

    .btn__down--text {
        display: inline-block;
        vertical-align: middle;
    }

    .btn__bg:hover {
        transform: translate(-50%, -50%) scale(1.5);
    }

    .btn__bg:hover ~ .btn__down--text {
        vertical-align: middle;
    }
   <div class="header__main--text">
        <h1 class="header__heading--primary usr-res">welcome</h1>
            <a href="#" class="btn btn__bg btn__content usr-res">
                <span class="btn__down--text">&downarrow;</span>
            </a>
    </div>

Any help would be appreciated!

Upvotes: 0

Views: 70

Answers (1)

Johannes
Johannes

Reputation: 67768

It's not really clear what you mean: The scaling works (?)

The vertical position of the arrow can be adjusted with a margin-top on the span which contains it.

.btn__bg {
    position: absolute;
    display: inline-block;
    opacity: 1;
    top: 75%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 60px;
    width: 60px;
    background-color: white;
    border-radius: 50%;
    text-align: center;
    animation: fadeInTop 1.2s forwards ease-out 1.5s;
    transition: all .2s;
    box-shadow: 0 4px 40px rgba(0,0,0,.3);
}

.btn__content {
    font-size: 30px;
    color: #000;
    font-weight: 100;
    text-decoration: none;
    line-height: normal;
}

.btn__down--text {
    display: inline-block;
    margin-top:0.3em;
}

.btn__bg:hover {
    transform: translate(-50%, -50%) scale(1.5);
}

.btn__bg:hover ~ .btn__down--text {
    vertical-align: middle;
}
<div class="header__main--text">
    <h1 class="header__heading--primary usr-res">welcome</h1>
        <a href="#" class="btn btn__bg btn__content usr-res">
            <span class="btn__down--text">&downarrow;</span>
        </a>
</div>

Upvotes: 2

Related Questions