3

I'm trying to emulate the button shown here: https://codepen.io/nw/pen/udkIB

I am trying to add my animation in the value button, but it's not working. The download arrow shape & download nox shape are not showing.

Here is my code:

.buttonDownload { display: inline-block; border: none; position: relative; padding: 10px 25px; background-color: #4CC713; color: white; font-family: sans-serif; text-decoration: none; font-size: 0.9em; text-align: center; text-indent: 15px; } .buttonDownload:hover { background-color: #333; color: white; } .buttonDownload:before, .buttonDownload:after { content: ' '; display: block; position: absolute; left: 15px; top: 52%; } /* Download box shape */ .buttonDownload:before { width: 10px; height: 2px; border-style: solid; border-width: 0 2px 2px; } /* Download arrow shape */ .buttonDownload:after { width: 0; height: 0; margin-left: 3px; margin-top: -7px; border-style: solid; border-width: 4px 4px 0 4px; border-color: transparent; border-top-color: inherit; -webkit-animation: downloadArrow 2s linear infinite; animation: downloadArrow 2s linear infinite; -webkit-animation-play-state: paused; animation-play-state: paused; } .buttonDownload:hover:before { border-color: #4CC713; } .buttonDownload:hover:after { border-top-color: #4CC713; -webkit-animation-play-state: running; animation-play-state: running; } /* keyframes for the download icon anim */ @-webkit-keyframes downloadArrow { /* 0% and 0.001% keyframes used as a hackish way of having the button frozen on a nice looking frame by default */ 0% { margin-top: -7px; opacity: 1; } 0.001% { margin-top: -15px; opacity: 0; } 50% { opacity: 1; } 100% { margin-top: 0; opacity: 0; } } @keyframes downloadArrow { /* 0% and 0.001% keyframes used as a hackish way of having the button frozen on a nice looking frame by default */ 0% { margin-top: -7px; opacity: 1; } 0.001% { margin-top: -15px; opacity: 0; } 50% { opacity: 1; } 100% { margin-top: 0; opacity: 0; } }
<form action="" method="POST"> <div class="g-recaptcha" data-sitekey="your_site_key"></div> <br/> <input type="submit" value="Download" class="buttonDownload"> </form>

2
  • Your form-action is invalid. Absolute action="" URIs must start with https:// http://, or //. Commented Dec 10, 2019 at 15:44
  • 1
    Why not just use the working code from the CodePen you're trying to emulate? Commented Dec 10, 2019 at 15:46

1 Answer 1

5

Pseudo-elements like :before and :after don't work on any <input> elements. In your linked example it works, because it uses a <a>

So you will have to replace this HTML:

<input type="submit" value="Download" class="buttonDownload"> 

with this:

<button type="submit" class="buttonDownload">Download</button> 

Demo: https://jsfiddle.net/fL2e6t8o/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.