CSS inverted curtain effect

Asked

Viewed 244 times

-1

Good

Basically I want to do the curtain effect backwards, I’ll make it clear in the prints!

When the person passes ( on Hover ) I wish I had a darker curtain and that went up, that is to say I would be covering.

img1

hover

At the moment I have the code like this:

.card {
display: inline-block;
position: relative;
}

.card::before {
    content: "";
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform-origin: top center;
    transform: scale3d(1, 0, 1);
    transition: 1s;
}

.card:hover::before {
    opacity: 1;
    transform: scale3d(1, 1, 1);
    visibility: visible;
}

example of what I want only that contrary: https://stackoverflow.com/questions/50979913/simple-curtain-effect-on-hover-using-pure-css

1 answer

1


Just change the top for bottom in transform-origin for the purpose of down instead of up-down and add property background-color: rgba(0, 0, 0, 1); in the hover of ::before so that the background becomes totally opaque after animation.

Behold:

.card {
display: inline-block;
position: relative;
width: 100px;;
height: 150px;
background: red;
}

.card::before {
    content: "";
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom center;
    transform: scale3d(1, 0, 1);
    transition: 1s;
}

.card:hover::before {
    opacity: 1;
    transform: scale3d(1, 1, 1);
    visibility: visible;
    background-color: rgba(0, 0, 0, 1);
}
<div class="card">
   Card
</div>

But there’s also another way a little bit simpler by increasing the height of the element ::before:

.card {
display: inline-block;
position: relative;
width: 100px;;
height: 150px;
background: red;
}

.card::before {
    content: "";
    width: 100%;
    height: 0;
    position: absolute;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: 1s;
}

.card:hover::before {
    opacity: 1;
    height: 100%;
    background-color: rgba(0, 0, 0, 1);
}
<div class="card">
   Card
</div>

  • thanks for the help but still not quite it, I wanted the background-color: rgba(0, 0, 0, 0.3); had already appeared and then is up to show the image :S

  • Then it would be two layers?

  • imagine, div card dps an img, then in effect I wanted the site to have already appearing overlay (curtain darker than the image) and that after that Hover she went up, I don’t know if I’m explaining well rsrs

  • See if that’s it: https://jsfiddle.net/vhyk5bc9/

  • aiii valeuuu, that’s right thanks guy <33

Browser other questions tagged

You are not signed in. Login or sign up in order to post.