Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <p>Passing interpolated vals from animation to element</p>
  <div></div>
  
  <p>Basic Keyframes with custom props</p>
  <div class="regular"></div>
  
  <p>Testing transitions via :hover</p>
  <div class="hover"></div>
</body>
</html>
 
div {
  --foo: green;
  border: 2px solid black;
  background: var(--foo); /* this is here to show order of sub */
  height: 100px;
  width: 100px;
  animation: test 1s infinite;
  transition: all 1s;
}
.hover:hover {
  --foo: blue;
  background: var(--foo);
}
.regular {
  --foo: red;
  animation: regular 1s infinite;
}
@keyframes test {
  from {
    --foo: red;
  }
  to {
    --foo: blue;
  }
}
/* This should transition the background from red to yellow */
@keyframes regular {
  from {
    background: var(--foo);
  }
  to {
    --foo: yellow;
    background: var(--foo);
  }
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers