Related
I have an SVG and it uses some css classes, the CSS classes are in a seperate file and I'm not really sure how to get them to connect. I can get other SVG's to display but this one won't, I suspect it's because I need to load the CSS classes that it's relying upon
here's the SVG
.loader-container {
position: relative;
}
/*------------------------------------*\
#OVERLAYS
\*------------------------------------*/
.set--overlay {
position: relative;
//Helps iOS detect taps on overlaid pseudo-element.
cursor: pointer;
}
//Forces overlay on top of everything.
//Limit to 20, so that other components can "punch through".
.set--overlay-all {
&:after {
z-index: 1080;
}
}
.loader,
.set--overlay:after {
position: absolute;
}
.loader,
.set--overlay:not(.header-container):after,
.page:after,
.header:after {
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.set--overlay:not(.header-container):after,
.page:after,
.header:after {
background-color: transparentize($color-black, 0.75);
transition: opacity $transition-speed-fast $transition-ease-default,
visibility $transition-speed-fast $transition-ease-default;
}
.set--overlay:not(.header-container),
.page,
.header {
&:after {
content: '';
}
}
/*------------------------------------*\
#LOADER
\*------------------------------------*/
//Local variables
$_loader-offset: 187;
$_loader-duration: 1.4s;
.loader {
z-index: 10000; //It's over 9000!. This should overlay *everything*.
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition-property: opacity, visibility;
transition-timing-function: $transition-ease-in;
transition-duration: $transition-speed-slow;
#include set-invisible();
&.set--alt {
background-color: transparentize($color-black, 0.75);
.loader-indicator__path {
//stroke: $color-white;
}
}
&:not(.set--alt) {
background-color: transparentize($color-white, 0.75);
.loader-indicator__path {
// stroke: $color-secondary;
}
}
&.set--fixed {
position: fixed;
.loader-indicator, .face-loader {
top: 50%;
transform: translateY(-50%);
}
}
&.set--visible {
transition-timing-function: $transition-ease-out;
transition-duration: $transition-speed-slow;
#include set-visible();
}
}
.face-loader-wrapper {
#eye-sx, #eye-dx {
fill: #c10016;
opacity: 0;
animation: eye 500ms 300ms ease infinite;
}
}
.loader-indicator {
position: absolute;
top: 0;
width: 100%;
height: 100%;
max-width: 5rem;
max-height: 5rem;
pointer-events: none;
}
.loader-indicator__path {
fill: #949494;
}
.hide {
position: absolute;
width: 0;
height: 0;
}
.face-loader {
position: absolute;
top: 0;
width: 80px;
height: 80px;
display: block;
clip-path: url(#clipping-face);
&:before {
content: '';
display: block;
background: #c10016;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: translateY(-100%);
animation: loader-horizontal 500ms 300ms ease forwards;
transform-origin: 0 0;
}
}
.face-loader--reverse {
&:before {
transform: translateY(100%);
animation: loader-horizontal-reverse 500ms 300ms ease forwards;
}
}
.loader-message {
max-width: 20.625rem;
padding: 0 1rem;
text-align: center;
font-weight: $font-weight-bold;
color: $color-secondary;
background-color: transparentize($color-white, .25);
}
//Credit: https://codepen.io/mrrocks/pen/EiplA
/*! rtl:begin:ignore */
#keyframes rotator {
0% { transform: rotate(0deg); }
100% { transform: rotate(270deg); }
}
#keyframes dash {
0% { stroke-dashoffset: $_loader-offset; }
50% {
stroke-dashoffset: $_loader-offset/4;
transform:rotate(135deg);
}
100% {
stroke-dashoffset: $_loader-offset;
transform:rotate(450deg);
}
}
#keyframes loader-horizontal {
from {
transform: translateY(-100%);
}
to {
transform: translateY(0);
}
}
#keyframes loader-horizontal-reverse {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
#keyframes eye {
0% {
opacity: 0.4;
}
50% {
opacity: 1;
}
55% {
opacity: 0.9;
}
60% {
opacity: 1;
}
80% {
opacity: 0.6;
}
100% {
opacity: 0.4;
}
}
/*! rtl:end:ignore */
<svg class="loader-indicator">
<g class="face">
<path class="loader-indicator__path" d="M57.89,40.39l-7.18-5,3.71-6.73h0L59.74,19l.93,4.89Zm-6.1,8.74L40.52,39.45,50,36.06l7.55,5.31ZM32.32,70c-5.08-.21-7.21-2.8-7.88-3.88l7.83-2.74,7.81,2.73C37.29,69.93,32.35,70,32.32,70ZM3.92,23.86l.93-4.92,5.33,9.67h0l3.72,6.73-7.2,5ZM1.09,4.65a.43.43,0,0,0,0-.12,3,3,0,0,1,.54-1.08C5.15,1.07,13.33,6.76,16.85,9.67l-12,7.1C.09,7.14,1.09,4.66,1.09,4.65Zm15.13.11L17,8.47C14.75,6.71,9.68,3,5.44,2.07c4.09,0,9.62,2.2,10.78,2.69ZM34.05,1c.09,0,5.51,0,13.27,3.67L42.55,31,32.8,28V1c.42,0,.83,0,1.25,0ZM59.23,2.08C55,3,49.8,6.79,47.64,8.52l.68-3.74C49.4,4.32,55.09,2,59.23,2.08ZM53.65,28l-10.07,3,3.7-20.39,12,7.14ZM21.6,32l2.53,6.39L14.9,35.09l-3.26-5.91Zm-.26-1.12L11,28,5.29,17.67l12.06-7.14ZM31.8,28l-9.44,3L17.23,4.7A49.12,49.12,0,0,1,31.8,1.07Zm1,8.53V29.05l9.46,2.88-3,6.72Zm-7.3,3.09,6.8-2.2L39,39.63V53.41H25.5Zm6.3-3.09-6.51,2.1-2.66-6.71,9.17-2.88Zm.49,22.3-5.81-4.43H38.07ZM7.05,41.35l7.57-5.29L24,39.44,12.79,49.11ZM13.25,50,24.5,40.35V53.61L15,58.71ZM23.8,65.28l-8.25-5.75,9.4-5,6.85,5.22v2.77Zm17,0-8-2.79V59.72l6.79-5.22,9.45,5Zm8.85-6.58L40,53.61V40.35l11.29,9.71Zm.08-23.62L40.48,38.4,43.31,32,53,29.19Zm10-18.32L47.82,9.67C51.3,6.76,59.43,1.1,62.92,3.46a3,3,0,0,1,.53,1.07l0,.1s1,2.51-3.73,12.14Zm.74.79c4.9-9.87,4.14-12.8,3.9-13.33a3.72,3.72,0,0,0-.69-1.36.22.22,0,0,0-.05-.08,3.92,3.92,0,0,0-1.41-1.11C58-.32,49.44,3.21,47.94,3.85,39.82,0,34.3,0,34.05,0,33.51,0,33,0,32.42,0L32.3,0a.58.58,0,0,0-.19,0A48.54,48.54,0,0,0,16.66,3.86C15.18,3.22,6.56-.32,2.34,1.68A4.16,4.16,0,0,0,.92,2.79l0,0a3.86,3.86,0,0,0-.71,1.4c-.24.53-1,3.46,3.9,13.32L2.92,23.76a.49.49,0,0,0,0,.17L5.84,41.31h0a.39.39,0,0,0,.08.2h0L12.24,50l1.87,9.53a.15.15,0,0,0,0,.07.64.64,0,0,0,0,.07h0a.43.43,0,0,0,.14.16l9,6.29c.39.79,2.58,4.56,9,4.83.24,0,5.94,0,8.94-4.81l9-6.31a.54.54,0,0,0,.14-.16h0a.1.1,0,0,0,0-.07.21.21,0,0,0,0-.07L52.35,50l6.31-8.51a.85.85,0,0,0,.09-.22l2.92-17.38a.49.49,0,0,0,0-.17Z">
</path>
</g>
<g class="eyes">
<polygon id="eye-sx" points="14.9 35.09 11.64 29.18 21.6 32.03 24.13 38.42 14.9 35.09"></polygon>
<polygon id="eye-dx" points="40.48 38.4 43.31 32.03 52.96 29.19 49.71 35.09 40.48 38.4"></polygon>
</g>
</svg>
I'm not really sure how make the image appear on the screen when I try I get the following errorerror
I'm confused about how the transition property works.
Does transition time mean actual time?
For example:
.panel-left,
.panel-right {
transition: all ease 30s;
]
You click on the play image and both sides open.
How come the 2 sides are open in less than 30 seconds?
Would I be using a different transition property to do that?
Would it be done a different way?
code https://jsfiddle.net/bfjcn4xk/
What would be the css property to use to set a time for how long it will take for the 2 sides to be fully open?
(function iife() {
"use strict";
function show(el) {
el.classList.remove("hide");
}
function hide(el) {
el.classList.add("hide");
}
function coverClickHandler(evt) {
const cover = evt.currentTarget;
hide(cover);
const curtain = document.querySelector(".curtain");
curtain.classList.add("slide");
const thewrap = curtain.parentElement.querySelector(".container");
show(thewrap);
}
const cover = document.querySelector(".jacketa");
cover.addEventListener("click", coverClickHandler);
}());
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
background: #353198;
}
.curtain {
position: relative;
width: 100%;
height: 100%;
}
.curtain.slide {
height: auto;
min-height: 100%;
overflow: hidden;
}
.panel-left,
.panel-right {
position: absolute;
height: 100%;
width: 50%;
top: 0%;
transition: all ease 30s;
/*background-image: url("https://picsum.photos/600");
background-size: cover;
background-repeat: no-repeat;
background-position: center;*/
overflow: hidden;
}
.panel-left {
left: 0;
/*background-color: rgb(91, 96, 106);*/
}
.panel-right {
right: 0;
/*background-color: rgb(229, 211, 211);*/
}
.panel-left::before,
.panel-right::before {
content: "";
position: absolute;
height: 100%;
width: 200%;
top: 0;
left: 0;
background-image: url("https://picsum.photos/1920/1080");
background-size: auto;
background-repeat: no-repeat;
background-position: 0 0;
}
.panel-right::before {
left: -100%;
}
.curtain.slide .panel-left {
transform: translateX(-100vw);
}
.curtain.slide .panel-right {
transform: translateX(100vw);
}
.outer {
display: table;
height: 100%;
margin: 0 auto;
}
.tcell {
display: table-cell;
vertical-align: middle;
}
.jacketa {
position: absolute;
width: 180px;
height: 180px;
cursor: pointer;
border-radius: 50%;
background: #130e85;
border: 3px solid #f91f6e;
box-sizing: border-box;
display: block !important;
}
.jacketa .coversvg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
cursor: pointer;
}
.jacketa .coversvg {
width: 70px;
height: 75.4px;
fill: none;
stroke-width: 4px;
stroke-miterlimit: 10;
}
.jacketa .coversvg .back {
stroke: #000;
opacity: 0.15;
}
.jacketa .coversvg .front {
stroke: #08f9ff;
stroke-dasharray: 150;
stroke-dashoffset: 1500;
animation: draw 20s infinite linear, flicker-1 2s linear 2s infinite both;
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes flicker-1 {
0%,
100% {
opacity: 1;
}
41.99% {
opacity: 1;
}
42% {
opacity: 0;
}
43% {
opacity: 0;
}
43.01% {
opacity: 1;
}
47.99% {
opacity: 1;
}
48% {
opacity: 0;
}
49% {
opacity: 0;
}
49.01% {
opacity: 1;
}
}
.split-wrap {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 180px;
height: 180px;
margin: auto;
border-radius: 50%;
box-shadow: 0 0 20px 2px #f9066bf7;
transition: 5s ease;
}
.j1 {
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 {
position: absolute;
left: 50%;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 .jacketa {
right: 0;
left: auto;
}
.curtain.slide .split-wrap {
box-shadow: 0 0 20px 2px rgba(249, 6, 167, 0);
}
.container {
height: auto;
}
.curtain.slide .j1 {
transform: translateX(-100vw);
}
.curtain.slide .j2 {
transform: translateX(100vw);
}
.container {
width: 990px;
height: 1530px;
margin: 100px auto;
padding: 25px;
overflow: hidden;
border-radius: 25px;
border: 2px solid #0059dd;
box-sizing: border-box;
background: #000000;
}
.container-top {
position: relative;
height: 310px;
margin: 0 0 45px 0;
border-radius: 25px;
border: 3px solid #0059dd;
box-sizing: border-box;
background: url("https://i.imgur.com/jEMIULl.jpg") no-repeat 0 0;
background-size: cover;
}
.hide {
display: none;
}
<div class="curtain">
<div class="outer">
<div class="tcell">
<div class="container hide">
<div class="container-top">
</div>
</div>
<div class="panel-left"> </div>
<div class="panel-right"> </div>
<div class="split-wrap">
<div class="j1">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
<div class="j2">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
Each of the two panels has width 50%. But to open them the CSS translates them by -100vw and 100vw respectively.
So, basically, they are moved further to the left and right than they need to be - they have disappeared from view before the transition time is up.
Try this experiment: change one of the panels translation to 100% - that means 100% of its width, not the container or the viewport's width. You will see that the right panel moves at about half the speed of the left one, it takes 30 seconds to get out of view.
.curtain.slide .panel-left {
transform: translateX(-100vw);
}
.curtain.slide .panel-right {
transform: translateX(100%);/* CHANGED */
}
I'm not sure why the code would have been written to translate in 100vw terms - 'normally' I would have translated an element its full (100%) width to get it out of view. Then it is very clear that the transition time is the time the element will take to disappear. So, either change your HTML to do as above, or reduce your transition time.
The image should look like this.
box-shadow added to the code:
Image
Instead, it is looking like this and I don't know why and how to fix it. Image
You can see the box-shadow is being cut off of the image on all 4 sides.
How do I fix it so that the image isn't being cut off?
Code: https://jsfiddle.net/8mgvn40u/
.curtain {
width: 550px;
height: 250px;
border-radius: 20px;
position: relative;
overflow: hidden;
background: #000000;
box-sizing: border-box;
}
.jacketa {
position: absolute;
width: 180px;
height: 180px;
cursor: pointer;
border-radius: 50%;
background: #130e85;
border: 3px solid #f91f6e;
box-sizing: border-box;
box-shadow: 0 0 20px 2px #f9066bf7;
}
.jacketa .coversvg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
cursor: pointer;
}
.jacketa .coversvg {
width: 70px;
height: 75.4px;
fill: none;
stroke-width: 4px;
stroke-miterlimit: 10;
}
.jacketa .coversvg .back {
stroke: #000;
opacity: 0.15;
}
.jacketa .coversvg .front {
stroke: #08f9ff;
stroke-dasharray: 150;
stroke-dashoffset: 1500;
animation: draw 20s infinite linear, flicker-1 2s linear 2s infinite both;
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes flicker-1 {
0%,
100% {
opacity: 1;
}
41.99% {
opacity: 1;
}
42% {
opacity: 0;
}
43% {
opacity: 0;
}
43.01% {
opacity: 1;
}
47.99% {
opacity: 1;
}
48% {
opacity: 0;
}
49% {
opacity: 0;
}
49.01% {
opacity: 1;
}
}
.split-wrap {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 180px;
height: 180px;
margin: auto;
border-radius: 50%;
transition: 0.5s ease;
}
.j1 {
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 {
position: absolute;
left: 50%;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 .jacketa {
right: 0;
left: auto;
}
.curtain:hover .j1 {
transform: translateX(-500%);
}
.curtain:hover .j2 {
transform: translateX(500%);
}
<div class="curtain">
<div class="split-wrap">
<div class="j1">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
<div class="j2">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
</div>
</div>
Because of overflow, bow-shadow gets cut-off (already said) , You could also use transform to easily keep the shadows within the visible area.
increase first the hidden overflow area then decrease what stands inside. smaller it won't get clipped anymore.
example of the idea with a short fixed involving : transform:scale(1.1)VS transform:scale(0.9) to keep a close ratio of the initial layout size.
.curtain {
width: 550px;
height: 250px;
border-radius: 20px;
position: relative;
overflow: hidden;
background: #000000;
box-sizing: border-box;
}
.split-wrap{
transform:scale(1.1);
}
.jacketa {
position: absolute;
width: 180px;
height: 180px;
cursor: pointer;
border-radius: 50%;
background: #130e85;
border: 3px solid #f91f6e;
box-sizing: border-box;
box-shadow: 0 0 20px 2px #f9066bf7;
transform:scale(0.9);
}
.jacketa .coversvg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
cursor: pointer;
}
.jacketa .coversvg {
width: 70px;
height: 75.4px;
fill: none;
stroke-width: 4px;
stroke-miterlimit: 10;
}
.jacketa .coversvg .back {
stroke: #000;
opacity: 0.15;
}
.jacketa .coversvg .front {
stroke: #08f9ff;
stroke-dasharray: 150;
stroke-dashoffset: 1500;
animation: draw 20s infinite linear, flicker-1 2s linear 2s infinite both;
}
#keyframes draw {
100% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 0;
}
}
#keyframes flicker-1 {
0%,
100% {
opacity: 1;
}
41.99% {
opacity: 1;
}
42% {
opacity: 0;
}
43% {
opacity: 0;
}
43.01% {
opacity: 1;
}
47.99% {
opacity: 1;
}
48% {
opacity: 0;
}
49% {
opacity: 0;
}
49.01% {
opacity: 1;
}
}
.split-wrap {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 180px;
height: 180px;
margin: auto;
border-radius: 50%;
transition: 0.5s ease;
}
.j1 {
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 {
position: absolute;
left: 50%;
top: 0;
width: 50%;
height: 100%;
overflow: hidden;
transition: 5s ease;
}
.j2 .jacketa {
right: 0;
left: auto;
}
.curtain:hover .j1 {
transform: translateX(-500%);
}
.curtain:hover .j2 {
transform: translateX(500%);
}
<div class="curtain">
<div class="split-wrap">
<div class="j1">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
<div class="j2">
<div class="jacketa" title="[ Enjoy The Music ]">
<svg class="coversvg" width="70" height="75.4" viewBox="0 0 47.96 51.66">
<title>[ Enjoy The Music ]</title>
<path class="back" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
<path class="front" d="M2,25.83V4.11A2.11,2.11,0,0,1,5.13,2.27L44.88,24.45a2.11,2.11,0,0,1,0,3.7L5.1,49.41A2.11,2.11,0,0,1,2,47.55V25.83" />
</svg>
</div>
</div>
</div>
</div>
that happening because you gave overflow: hidden to .j1 and .j2, changing it into overflow: visible will fix the box-shadow issue but will mess up your curtain animation.
alternatively you can make .j1 and .j2 bigger but with padding so the box-shadow won't overlap it.
I have found a checkbox which I really want to use but when I add more than 1 checkbox the animation only applies to the first one.
I have tried creating new class's like .cbx2 and .inp-cbx2 and applying the same style's but the animation still only applies to the first checkbox.
Could you please explain where I'm going wrong?
Thanks.
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx span:last-child {
padding-left: 8px;
}
.cbx:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx:checked + .cbx span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx:checked + .cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx:checked + .cbx span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx2 {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx2 span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx2 span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx2 span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx2 span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx2 span:last-child {
padding-left: 8px;
}
.cbx2:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx2:checked + .cbx2 span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx2:checked + .cbx2 span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx2:checked + .cbx2 span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="cbx" type="checkbox" style="display: none;"/>
<label class="cbx" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>DIRECT</span></label>
<input class="inp-cbx2" id="cbx2" type="checkbox" style="display: none;"/>
<label class="cbx2" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10" class="c">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>MUTI ROUTE</span></label>
The whole reason classes exist in CSS is to make your styles reusable across multiple elements. There is no need to duplicate your CSS.
The reason the second check box doesn't work when using the same classes as the first is because you haven't updated the second labels for property. This property tells the browser the id of the form element that should be effected when the label is clicked.
In your case, the second label should look like this:
<label class="cbx" for="cbx2"><span>
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx span:last-child {
padding-left: 8px;
}
.cbx:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx:checked+.cbx span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx:checked+.cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx:checked+.cbx span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="cbx" type="checkbox" style="display: none;" />
<label class="cbx" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>DIRECT</span></label>
<input class="inp-cbx" id="cbx2" type="checkbox" style="display: none;" />
<label class="cbx" for="cbx2"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10" class="c">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>MUTI ROUTE</span></label>
Helo Guys!
I was trying to create a spinning hover effect with CSS3.
Just made a circle spinning effect. Check the jsFiddle here: http://jsfiddle.net/63yyeezn/26/
However what I want to do now is to create something tthat spins but this time its box type
just like this image:
So basically I want similar effect just like the jsFiddle I shown above however this time it must be box.
Really having a hard time figuring this out. Here's my CSS:
body {
background: #292929;
padding-left: 30px;
font-size: 12px;
}
.twist {
display: inline-block;
font-size: 45px;
line-height: 90px;
cursor: pointer;
margin: 20px;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
text-decoration: none;
z-index: 1;
color: #fff;
}
.twist:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content:'';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.twist:before {
speak: none;
font-size: 48px;
line-height: 90px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
-webkit-font-smoothing: antialiased;
}
.twist.demo-4 {
width: 92px;
height: 92px;
box-shadow: 0 0 0 4px rgba(255, 255, 255, 1);
}
.twist.demo-4:before {
line-height: 92px;
}
.twist.demo-4:after {
top: -4px;
left: -4px;
padding: 0;
z-index: 10;
border: 4px dashed #fff;
}
.twist.demo-4:hover {
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
color: #fff;
}
.twist.demo-4:hover i {
color: #fff;
}
.twist.demo-4.spin:hover {
-webkit-transition: box-shadow 0.2s;
-moz-transition: box-shadow 0.2s;
transition: box-shadow 0.2s;
}
.twist.demo-4.spin:hover:after {
-webkit-animation: spinAround 9s linear infinite;
-moz-animation: spinAround 9s linear infinite;
animation: spinAround 9s linear infinite;
}
#-webkit-keyframes spinAround {
from {
-webkit-transform: rotate(0deg)
}
to {
-webkit-transform: rotate(360deg);
}
}
#-moz-keyframes spinAround {
from {
-moz-transform: rotate(0deg)
}
to {
-moz-transform: rotate(360deg);
}
}
#keyframes spinAround {
from {
transform: rotate(0deg)
}
to {
transform: rotate(360deg);
}
}
Hope you can help me with a jsFiddle file.
Thanks!
My answer won't fit exactly your example, but may interest you as it's a full-CSS3 solution, without HTML markup change. The animation won't be a rotation, but a translation.
Webkit version
.bordered {
overflow: hidden;
}
.bordered:before {
content: '';
position: absolute;
top: 5px; /* 5px: border width */
left: 5px;
right: 5px;
bottom: 5px;
background: white;
z-index: -1;
}
.bordered:after {
content: '';
position: absolute;
top: -50%;
left: -50%;
right: -50%;
bottom: -50%;
background: black;
z-index: -2;
}
.bordered:hover:after {
background: -webkit-linear-gradient(left, white 50%, black 50%); /* black: border color*/
background-size: 20px 100%; /* 20px: dash width */
-webkit-animation: borderAnimated 1s linear infinite;
}
#-webkit-keyframes borderAnimated {
from {
transform: rotate(45deg) translate(0, 0);
}
to {
transform: rotate(45deg) translate(20px, 0);
}
}
/* --- Style only--- */
.bordered {
width: 150px;
height: 150px;
line-height: 150px;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="bordered">Lorem ipsum</div>
The trick is to have a stripped background in the :after pseudo-element, and a fake empty background in the :before element, which will work as a mask. When hovering your element, you just have to animate the :after pseudo-element to get something nice.
Credits: #vsynz
I don't think it can be possible only with static borders. Here is an alternative solution:
.rotating-dashed {
position: relative;
margin: 40px auto;
width: 90px;
height: 90px;
overflow: hidden;
color: #268;
}
.rotating-dashed .dashing {
display: block;
width: 100%;
height: 100%;
position: absolute;
}
.rotating-dashed .dashing:nth-of-type(2) {
-webkit-transform: rotate(90deg);
}
.rotating-dashed .dashing:nth-of-type(3) {
-webkit-transform: rotate(180deg);
}
.rotating-dashed .dashing:nth-of-type(4) {
-webkit-transform: rotate(270deg);
}
.rotating-dashed .dashing i {
display: block;
position: absolute;
left: 0;
top: 0;
width: 200%;
border-bottom: 5px solid
}
.rotating-dashed strong {
display: block;
width: 105%;
line-height: 90px;
text-align: center;
position: absolute;
}
.rotating-dashed:hover {
cursor: pointer;
}
.rotating-dashed:hover .dashing i {
-webkit-animation: slideDash 2.5s infinite linear;
border-bottom: 5px dashed
}
#-webkit-keyframes slideDash {
from {
-webkit-transform: translateX(-50%);
}
to {
-webkit-transform: translateX(0%);
}
}
<div class="rotating-dashed"> <span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<strong>Demo</strong>
</div>