.gradient-button { position: relative; background-color: transparent; } .gradient-button:after { content: ''; display: block; z-index: -1; position: absolute; top: -2rem; right: 0; bottom: -2rem; left: 0; background-image: linear-gradient(red, yellow, green); animation: rotate-gradient linear 1s infinite; } @keyframes rotate-gradient { to { transform: rotate(360deg) } }#test { color: #d3d3d3; background-color: #003366; background-image:linear-gradient(0deg, rgba(255, 255, 255, 0.6) 0px, rgba(255, 255, 255, 0) 100%); height: 200px; width: 500px; }