0
.body {
    background-color: #18181a;
    color: white;
    font-size: 2.5rem;
    margin-left: 0%;
    border-radius: 5px;
}

.body  .card{
    background:linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(0,212,255,0) 100%),url("./images/yuuki_mikan_bg.jpg");
    background-repeat: no-repeat;
    background-position: right;

    width: 90%;
    height: 80%;
    border-radius: 10px;
    margin: 10px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: space-between;
    flex-direction: row-reverse;

    transition: background 0.5s linear;
}

.body .card:hover {
    background:linear-gradient(90deg, rgba(0,0,0,0.17690826330532217) 0%, rgba(0,212,255,0) 100%),url("./images/yuuki_mikan_bg.jpg");
    background-position: right;
}

.body  .card .card_img{
    max-width: 80%;
    max-height: 95%;
    border-radius: 5px;
    /* bottom: 9px; */
    /* left: -10px; */
    /* top: -10px; */
    transition: 0.5s;
    opacity: 1;
    display: flex;
    justify-content: flex-start;
    align-self: center;
}

.body  .card .card_name{
    margin-right: 2%;
    margin-top: auto;
    margin-bottom: auto;
    font-size: 2.5rem;
    text-shadow: 0px 0px 18px black;
    opacity: 1;
}

this is the code im using, whenever i hover over .card, it changes the background color but transition doesn't delay its transition time. If you want more context, this is the website my code is running at https://oniichann.tk/waifus

Onii-Chan
  • 57
  • 1
  • 6

1 Answers1

1

I believe the only animatable property on a background gradient is background-position.

You may be able to achieve what you're looking for by doing something like the following:

.card {
  position: relative;
  text-align: center;
  color: white;
  padding: 100px;
  background: url("https://oniichann.tk/waifus/images/bg.jpg");
  background-repeat: no-repeat;
  background-position: right;
  background-size: cover;
}

.card:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  background-size: 200% 200%;
  transition: background-position 0.5s linear;
}

.card:hover:before {
  background-position: 100% 50%;
}
<div class="card"></div>
Ali Klein
  • 1,811
  • 13
  • 13