An holding overlay with animated spinner. Prefix-less for now but will need the -webkit extras.
A Pen by Grant Bunyan on CodePen.
An holding overlay with animated spinner. Prefix-less for now but will need the -webkit extras.
A Pen by Grant Bunyan on CodePen.
| <!-- Nothing to see here --> | |
| <div class="my-content"> | |
| <button type="submit">Some content I want to disable while busy</button> | |
| </div> | |
| <!-- Markup for the overlay and spinner should be placed directly before the closing </body> tag. Once that's in place all you'll need to do is toggle the classname 'hold-waiting' on and off with your favourite flavor of JS to enable the overlay activation --> | |
| <div class="hold hold--waiting"> | |
| <div class="spinner"> | |
| <span class="spinner__side spinner__side--left"> | |
| <span class="spinner__fill"></span> | |
| </span> | |
| <span class="spinner__side spinner__side--right"> | |
| <span class="spinner__fill"></span> | |
| </span> | |
| </div> | |
| </div> |
Forked from Captain Anonymous's Pen QwOGXb.
A Pen by Grant Bunyan on CodePen.
| /* | |
| Spinner and overlay styles | |
| */ | |
| @-webkit-keyframes spinner-rotate-right { | |
| 0% { -webkit-transform: rotate(0deg); } | |
| 25% { -webkit-transform: rotate(180deg); } | |
| 50% { -webkit-transform: rotate(180deg); } | |
| 75% { -webkit-transform: rotate(360deg); } | |
| 100% { -webkit-transform: rotate(360deg); } | |
| } | |
| @keyframes spinner-rotate-right { | |
| 0% { transform: rotate(0deg); } | |
| 25% { transform: rotate(180deg); } | |
| 50% { transform: rotate(180deg); } | |
| 75% { transform: rotate(360deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| @-webkit-keyframes spinner-rotate-left { | |
| 0% { -webkit-transform: rotate(0deg); } | |
| 25% { -webkit-transform: rotate(0deg); } | |
| 50% { -webkit-transform: rotate(180deg); } | |
| 75% { -webkit-transform: rotate(180deg); } | |
| 100% { -webkit-transform: rotate(360deg); } | |
| } | |
| @keyframes spinner-rotate-left { | |
| 0% { transform: rotate(0deg); } | |
| 25% { transform: rotate(0deg); } | |
| 50% { transform: rotate(180deg); } | |
| 75% { transform: rotate(180deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .hold { | |
| position: absolute; | |
| top: 0; | |
| right: 0; | |
| bottom: 0; | |
| left: 0; | |
| background: rgba(0,0,0,.4); | |
| opacity: 0; | |
| transition: opacity 1s; | |
| z-index: -1; | |
| } | |
| .hold--waiting { | |
| opacity: 1; | |
| transition: opacity 1s; | |
| z-index: inherit; | |
| } | |
| .hold:hover { | |
| cursor: progress; | |
| } | |
| .spinner { | |
| position: absolute; | |
| top: 50%; | |
| left: 50%; | |
| width: 46px; | |
| height: 46px; | |
| margin-top: -23px; | |
| margin-left: -23px; | |
| border-radius: 100%; | |
| background: rgba(26,23,24,0.05); | |
| } | |
| .spinner:after { | |
| content:""; | |
| background: rgba(254,254,254,0.2); | |
| position: absolute; | |
| width: 28px; | |
| height: 28px; | |
| border-radius: 50%; | |
| top: 9px; | |
| left: 9px; | |
| display: block; | |
| } | |
| .spinner__fill { | |
| border-radius: 999px; | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; | |
| background: rgba(26,23,24,0.1); | |
| opacity: 0.8; | |
| -webkit-animation-duration: 2s; | |
| -webkit-animation-iteration-count: infinite; | |
| -webkit-animation-timing-function: linear; | |
| -webkit-transform: translateZ(0); /* force hardware rendering */ | |
| animation-duration: 2s; | |
| animation-iteration-count: infinite; | |
| animation-timing-function: linear; | |
| } | |
| .spinner__side { | |
| width: 50%; | |
| height: 100%; | |
| overflow: hidden; | |
| position: absolute; | |
| } | |
| .spinner__side--left { | |
| left: 0 | |
| } | |
| .spinner__side--right { | |
| left: 50%; | |
| } | |
| .spinner__side--left .spinner__fill { | |
| left: 100%; | |
| border-top-left-radius: 0; | |
| border-bottom-left-radius: 0; | |
| } | |
| .spinner__side--right .spinner__fill { | |
| left: -100%; | |
| border-top-right-radius: 0; | |
| border-bottom-right-radius: 0; | |
| } | |
| .hold--waiting .spinner__side--left .spinner__fill { | |
| -webkit-animation-name: spinner-rotate-left; | |
| -webkit-transform-origin: 0 50%; | |
| animation-name: spinner-rotate-left; | |
| transform-origin: 0 50%; | |
| } | |
| .hold--waiting .spinner__side--right .spinner__fill { | |
| -webkit-animation-name: spinner-rotate-right; | |
| -webkit-transform-origin: 100% 50%; | |
| animation-name: spinner-rotate-right; | |
| transform-origin: 100% 50%; | |
| } | |
| /* | |
| Styles for the example | |
| */ | |
| .my-content { | |
| text-align: center; | |
| width: 30%; | |
| margin: 40% auto 0 auto; | |
| } |