Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created September 13, 2017 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeMyUI/939ba3e6c77fdb9e7d8f0e309c8d49ae to your computer and use it in GitHub Desktop.
Save CodeMyUI/939ba3e6c77fdb9e7d8f0e309c8d49ae to your computer and use it in GitHub Desktop.
Sliding Diagonals Background Effect
<div class="bg"></div>
<div class="bg bg2"></div>
<div class="bg bg3"></div>
<div class="content">
<h1>Sliding Diagonals Background Effect</h1>
</div>
html {
height:100%;
}
body {
margin:0;
}
.bg {
animation:slide 3s ease-in-out infinite alternate;
background-image: linear-gradient(-60deg, #6c3 50%, #09f 50%);
bottom:0;
left:-50%;
opacity:.5;
position:fixed;
right:-50%;
top:0;
z-index:-1;
}
.bg2 {
animation-direction:alternate-reverse;
animation-duration:4s;
}
.bg3 {
animation-duration:5s;
}
.content {
background-color:rgba(255,255,255,.8);
border-radius:.25em;
box-shadow:0 0 .25em rgba(0,0,0,.25);
box-sizing:border-box;
left:50%;
padding:10vmin;
position:fixed;
text-align:center;
top:50%;
transform:translate(-50%, -50%);
}
h1 {
font-family:monospace;
}
@keyframes slide {
0% {
transform:translateX(-25%);
}
100% {
transform:translateX(25%);
}
}
@01Kuzma
Copy link

01Kuzma commented Feb 10, 2018

Hello!
How it could be changed with the flex help in order to bind animation not to the whole background, but to .content box only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment