Safari CSS issue (Z-index? transform?) - css

I've been struggling with this for a week or so, but don't feel close to fixing it. So I'm coming to Stack Overflow for the first time, hello!
I built a nifty little card amount selector that allows users to select a card in a visual way.
If you want to see it in action, please look at my CodePen!
It works fine in Chrome, but when I open it in Safari, the animation of the shadow and the z-index seems to take a moment to catch up.
I've tried adding the below to CSS, to no avail.
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
I'd appreciate anyone's help!
ReactJS
const { useState } = React;
function CardAmount(props) {
const cardAmounts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const [cardAmount, setCardAmount] = useState(1);
function cardClick(e) {
const amount = Number.parseInt(e.target.id) + 1;
if (amount !== cardAmount) {
setCardAmount(amount);
}
}
function cardvCards(num) {
if (num === 0) {
return <p>card</p>;
} else {
return <p>cards</p>;
}
}
function animateCard(cardNumber) {
if (cardNumber < cardAmount) {
return "FrontFacing";
} else {
return "BackFacing";
}
}
//makeCards
function makeCards() {
return cardAmounts.map((d, i) => {
return (
<div className={animateCard(i)} key={"card_" + i}>
<div className="cardFront" id={i} onMouseEnter={cardClick}>
<div className="borderbox">
<h1>{d}</h1>
{cardvCards(i)}
</div>
</div>
<div className="cardBack" id={i} onMouseEnter={cardClick}></div>
</div>
);
});
}
return (
<div className="CardChoice">
<div className="cardAmountDisplay">{makeCards()}</div>
</div>
);
}
ReactDOM.render(<CardAmount />, document.getElementById("app"));
CSS
#app {
background-color: rgb(85, 26, 122);
width: 100vw;
height: 100vh;
}
h1 {
text-align: center;
}
p {
text-align: center;
}
.CardChoice {
display: flex;
align-items: center;
justify-content: center;
height: 180px;
}
.cardAmountDisplay {
display: flex;
position: relative;
}
.FrontFacing,
.BackFacing {
position: absolute;
background-color: white;
border: 1px solid #d4af37;
border-radius: 10px;
margin: 5px;
height: 165px;
width: 115px;
transition: 750ms;
-webkit-transition: 750ms;
-moz-transition: 750ms;
-o-transition: 750ms;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
box-shadow: -8px 2px 8px rgba(0, 0, 0, 0.5);
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
.BackFacing {
transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
}
.cardFront,
.cardBack {
position: absolute;
width: 100%;
height: 100%;
border-radius: 10px;
background-color: white;
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
.cardFront {
display: flex;
justify-content: center;
align-items: center;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
}
.borderbox {
background-color: white;
width: 95%;
height: 95%;
border: 1px solid #d4af37;
border-radius: 10px;
margin-left: 1px;
pointer-events: none;
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
.cardFront h1 {
font-size: 80px;
color: #d4af37;
text-shadow: 1px 0px rgb(0, 0, 0), -1px 0px rgb(0, 0, 0), 0px 1px rgb(0, 0, 0),
0px -1px rgb(0, 0, 0);
margin-top: 15px;
margin-bottom: 0px;
pointer-events: none;
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
.cardFront p {
font-size: 16px;
font-weight: 600;
color: #d4af37;
text-transform: uppercase;
pointer-events: none;
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
.cardBack {
transform: rotateY(-180deg);
-webkit-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
-o-transform: rotateY(-180deg);
}
.FrontFacing:nth-child(1) {
margin-left: -280px;
z-index: 1;
}
.FrontFacing:nth-child(2) {
margin-left: -240px;
z-index: 2;
}
.FrontFacing:nth-child(3) {
margin-left: -200px;
z-index: 3;
}
.FrontFacing:nth-child(4) {
margin-left: -160px;
z-index: 4;
}
.FrontFacing:nth-child(5) {
margin-left: -120px;
z-index: 5;
}
.FrontFacing:nth-child(6) {
margin-left: -80px;
z-index: 6;
}
.FrontFacing:nth-child(7) {
margin-left: -40px;
z-index: 7;
}
.FrontFacing:nth-child(8) {
margin-left: 0px;
z-index: 8;
}
.FrontFacing:nth-child(9) {
margin-left: 40px;
z-index: 9;
}
.FrontFacing:nth-child(10) {
margin-left: 80px;
z-index: 10;
}
.BackFacing:nth-child(2) {
margin-left: -140px;
z-index: 9;
}
.BackFacing:nth-child(3) {
margin-left: -100px;
z-index: 8;
}
.BackFacing:nth-child(4) {
margin-left: -60px;
z-index: 7;
}
.BackFacing:nth-child(5) {
margin-left: -20px;
z-index: 6;
}
.BackFacing:nth-child(6) {
margin-left: 20px;
z-index: 5;
}
.BackFacing:nth-child(7) {
margin-left: 60px;
z-index: 4;
}
.BackFacing:nth-child(8) {
margin-left: 100px;
z-index: 3;
}
.BackFacing:nth-child(9) {
margin-left: 140px;
z-index: 2;
}
.BackFacing:nth-child(10) {
margin-left: 180px;
z-index: 1;
}

Related

Drop down menu in CSS not working as should

Anyone know why this wont work correctly? The dropdown should only appear when you hovet on the menu name but it appears if you hover below the item name and the longer the menu list the further beneath it you can hover to make it drop down. For example if you hover below the menu name "skills" the dropdown appears instead of only appearing when you click ON the name or hover over it.
<!DOCTYPE html>
<html>
<head>
<style>
$min-width: 120px;
$secondarycolor: #CCFF00;
$thirdcolor: #000000;
#mixin transform($value) {
-webkit-transform: ($value);
-moz-transform: ($value);
-ms-transform: ($value);
transform: ($value);
}
#mixin transition($value) {
-webkit-transition: ($value);
-moz-transition: ($value);
-ms-transition: ($value);
transition: ($value);
}
*{
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
color: #CCFF00;
background: #374954;
text-align: center;
}
#main {
position: relative;
list-style: none;
background-image: url('https://tc-boxing.com/pic/gradient.png');
background-repeat: repeat-x no-repeat-y;
font-weight: 600;
font-size: 0;
text-transform: uppercase;
display: inline-block;
padding: 0;
margin: 50px auto;
li {
font-size: 0.8rem;
display: inline-block;
position: relative;
padding: 15px 20px;
cursor: pointer;
z-index: 5;
min-width: $min-width;
}
}
li {
margin: 0;
}
.drop {
overflow: hidden;
list-style: none;
position: absolute;
padding: 0;
width: 100%;
left: 0;
top: 48px;
div {
#include transform(translate(0,-100%));
#include transition(all 0.5s 0.1s);
position: relative;
}
li {
display:block;
padding: 0;
width: 100%;
background-image: url('https://tc-boxing.net/pic/gradientdd2.png') !important;
background-repeat: repeat-x no-repeat-y;
}
}
#marker {
height: 6px;
background: $secondarycolor !important;
position: absolute;
bottom: 0;
width: $min-width;
z-index: 2; #include transition(all 0.35s);
}
#for $i from 1 through 4 {
#main li:nth-child(#{$i}) {
&:hover ul div {
#include transform(translate(0,0));
}
&:hover ~ #marker {
#include transform(translate(#{(-1+$i)*$min-width},0));
}
}
}
* {
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
background: #374954;
color: #CCFF00;
text-align: center;
}
#main {
position: relative;
list-style: none;
background-image: url('https://tc-boxing.com/pic/gradient.png');
background-repeat: repeat-x no-repeat-y;
font-weight: 600;
font-size: 0;
text-transform: uppercase;
display: inline-block;
padding: 0;
margin: 50px auto;
}
#main li {
font-size: 0.8rem;
display: inline-block;
position: relative;
padding: 15px 20px;
cursor: pointer;
z-index: 5;
min-width: 120px;
}
li {
margin: 0;
}
.drop {
overflow: hidden;
list-style: none;
position: absolute;
padding: 0;
width: 100%;
left: 0;
top: 48px;
}
.drop div {
-webkit-transform: translate(0, -100%);
-moz-transform: translate(0, -100%);
-ms-transform: translate(0, -100%);
transform: translate(0, -100%);
-webkit-transition: all 0.5s 0.1s;
-moz-transition: all 0.5s 0.1s;
-ms-transition: all 0.5s 0.1s;
transition: all 0.5s 0.1s;
position: relative;
}
.drop li {
display: block;
padding: 0;
width: 100%;
background-image: url('https://tc-boxing.net/pic/gradientdd.png') !important;
background-repeat: repeat-x no-repeat-y;
}
#marker {
height: 4px;
background: #CCFF00 !important;
position: absolute;
bottom: 0;
width: 120px;
z-index: 2;
-webkit-transition: all 0.35s;
-moz-transition: all 0.35s;
-ms-transition: all 0.35s;
transition: all 0.35s;
}
#main li:nth-child(1):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(1):hover ~ #marker {
-webkit-transform: translate(0px, 0);
-moz-transform: translate(0px, 0);
-ms-transform: translate(0px, 0);
transform: translate(0px, 0);
}
#main li:nth-child(2):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(2):hover ~ #marker {
-webkit-transform: translate(120px, 0);
-moz-transform: translate(120px, 0);
-ms-transform: translate(120px, 0);
transform: translate(120px, 0);
}
#main li:nth-child(3):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(3):hover ~ #marker {
-webkit-transform: translate(240px, 0);
-moz-transform: translate(240px, 0);
-ms-transform: translate(240px, 0);
transform: translate(240px, 0);
}
#main li:nth-child(4):hover ul div {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#main li:nth-child(4):hover ~ #marker {
-webkit-transform: translate(360px, 0);
-moz-transform: translate(360px, 0);
-ms-transform: translate(360px, 0);
transform: translate(360px, 0);
}
</style>
</head>
<body>
<!-- not responsive yet -->
<nav>
<ul id="main">
<li>Home</li>
<li>About</li>
<li>Skills
<ul class="drop">
<div>
<li>scss</li>
<li>jquery</li>
<li>html</li>
</div>
</ul>
</li>
<li>Contact</li>
<div id="marker"></div>
</ul>
</nav>
</body>
</html>
https://codepen.io/dghez/pen/Kwoper
Try adding::
#main li {
visibility: hidden;
}
#main li:hover ul {
visibility: visible;
}

Chceckbox :checked animation is laggy only for the first time

I want to create pure CSS, animated checkbox. everything is fine except the moment when I load the page with my checkbox and it has pseudoclass :checked. When I uncheck it for the first time, the animation (BounceIn) is laggy.
I tried using transition, but the effect is the same.
.checkbox {
cursor: pointer;
position: relative;
}
.checkbox .icon {
color: #fff;
left: 0;
position: absolute;
stroke-dasharray: 18;
stroke-dashoffset: 18;
top: 0;
}
.checkbox .icon {
left: 0;
position: absolute;
stroke-dasharray: 18;
stroke-dashoffset: 18;
top: 0;
}
.checkbox input[type="checkbox"]:checked+.input__row .icon,
.checkbox input[type="checkbox"]:checked .icon {
stroke-dashoffset: 0;
}
.checkbox input[type="checkbox"]:focus:checked+.input__row .icon {
stroke-dashoffset: 0;
transition: stroke-dashoffset 0.15s ease-out 0.25s;
}
.checkbox input[type="checkbox"]:focus:not(:disabled)+div .checkbox__field,
.checkbox input[type="checkbox"]:hover:not(:disabled)+div .checkbox__field {
border: 2px solid #4680fe;
box-shadow: 0 1px 1px rgba(70, 128, 254, 0.1);
}
.checkbox--compact .checkbox__anims,
.checkbox--compact .checkbox__field,
.checkbox--compact .checkbox__toggle .icon {
height: 18px;
width: 18px;
}
.checkbox--disabled {
cursor: not-allowed;
}
.checkbox--disabled input[type="checkbox"] {
pointer-events: none;
}
.checkbox.checkbox--compact input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el {
transform-origin: 12px 1px;
}
.checkbox.checkbox--disabled input[type="checkbox"]:not(:checked)+.input__row .checkbox__field {
background-color: rgba(70, 128, 254, 0.1);
border-color: rgba(70, 128, 254, 0.2);
}
.checkbox.checkbox--disabled .checkbox__field,
.checkbox.checkbox--disabled .icon {
opacity: 0.5;
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el {
left: 0;
margin: -1px 0 0 -4px;
position: absolute;
top: 50%;
transform-origin: 16px 1px;
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el:after {
content: "";
display: block;
height: 2px;
opacity: 0.4;
transform: translateX(0) scaleX(0);
transform-origin: left center;
width: 4px;
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el:first-child {
transform: rotate(45deg);
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el:nth-child(2) {
transform: rotate(135deg);
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el:nth-child(3) {
transform: rotate(225deg);
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__anims .checkbox__anims-el:nth-child(4) {
transform: rotate(315deg);
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:checked+.input__row .checkbox__field {
animation: elementBounceIn .6s ease 0ms 1 forwards;
}
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:focus:checked+.input__row checkbox__anims .checkbox__anims-el:after {
animation: linesScaleIn .4s ease .1s 1 forwards;
}
.checkbox__anims {
display: block;
height: 24px;
left: 0;
position: absolute;
top: 0;
width: 24px;
}
.checkbox__anims .checkbox__anims-el:after,
.checkbox input[type="checkbox"]:checked+.input__row .checkbox__field {
background-color: #4680fe;
}
.checkbox__field {
border: 2px solid rgba(70, 128, 254, 0.4);
border-radius: 3px;
box-shadow: 0 1px 1px rgba(70, 128, 254, 0.1);
box-sizing: border-box;
height: 24px;
position: relative;
width: 24px;
}
.checkbox__toggle {
position: relative;
}
.icon {
display: inline-block;
fill: currentColor;
height: 24px;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-miterlimit: 10;
stroke-width: 0;
transition: stroke 0.25s linear, fill 0.25s linear;
width: 24px;
}
.icon--fill-none {
fill: none;
}
.icon--stroke-width-primary {
stroke-width: 2px;
}
.input--hidden {
cursor: inherit;
height: 100%;
left: 0;
margin: 0;
opacity: 0;
padding: 0;
pointer-events: all;
position: absolute;
width: 100%;
z-index: 1;
}
.input__row {
display: flex;
height: 100%;
width: 100%;
}
#keyframes elementBounceIn {
0% {
transform: matrix(0, 0, 0, 0, 0, 0);
}
5.81% {
transform: matrix(0.483, 0, 0, 0.483, 0, 0);
}
11.61% {
transform: matrix(0.88, 0, 0, 0.88, 0, 0);
}
17.42% {
transform: matrix(1.09, 0, 0, 1.09, 0, 0);
}
23.12% {
transform: matrix(1.142, 0, 0, 1.142, 0, 0);
}
30.33% {
transform: matrix(1.098, 0, 0, 1.098, 0, 0);
}
37.44% {
transform: matrix(1.033, 0, 0, 1.033, 0, 0);
}
44.54% {
transform: matrix(0.994, 0, 0, 0.994, 0, 0);
}
51.65% {
transform: matrix(0.984, 0, 0, 0.984, 0, 0);
}
80.28% {
transform: matrix(1.002, 0, 0, 1.002, 0, 0);
}
to {
transform: matrix(1, 0, 0, 1, 0, 0);
}
}
#keyframes linesScaleIn {
0% {
transform: translateX(0) scaleX(0)
}
50% {
transform: translateX(-12px) scaleX(2)
}
51% {
transform: translateX(-12px) scaleX(2)
}
to {
transform: translateX(-12px) scaleX(0)
}
}
<div class="input checkbox">
<input type="checkbox" class="input--hidden" checked>
<div class="input__row">
<div class="checkbox__toggle">
<span class="checkbox__anims-el"></span>
<span class="checkbox__anims-el"></span>
<span class="checkbox__anims-el"></span>
<span class="checkbox__anims-el"></span>
</div>
<div class="checkbox__field"></div>
<svg class="icon icon__tick icon--ot" viewBox="0 0 24 24">
<title>tick</title>
<polyline class="icon--fill-none icon--stroke-width-primary"
points="6.34 11.29 10.59 15.54 17.66 8.46"></polyline>
</svg>
</div>
<div class="input__label-wrapper">
<div class="label">Uncheck it and see</div>
</div>
</div>
https://codepen.io/piokrako/pen/rELvdd?editors=1100
.checkbox:not(.checkbox--disabled) input[type="checkbox"]:focus:checked + .input__row .checkbox__field { animation: elementBounceIn .6s ease 0ms 1 forwards; }

Display a W with an effect of fade out

I want to display a W with an effect of fade out when my W will be written entirely.
I do not know if I got tangled in my Keyframes
.anim {
transform: rotate(90deg);
}
#global {
width: 70px;
margin: auto;
zoom: 1.9;
margin-top: 100px;
position: relative;
cursor: pointer;
height: 60px;
}
.mask {
position: absolute;
border-radius: 2px;
overflow: hidden;
perspective: 1000;
backface-visibility: hidden;
}
.plane {
background: #2a6fed;
width: 400%;
height: 100%;
position: absolute;
transform: translate3d(0px, 0, 0);
/*transition: all 0.8s ease; */
z-index: 100;
perspective: 1000;
backface-visibility: hidden;
}
.animation {
transition: all 0.3s ease;
}
#top .plane {
z-index: 2000;
animation: trans3 3s ease-out infinite 0s backwards;
}
#middle .plane {
transform: translate3d(0px, 0, 0);
background: #2358be;
animation: trans2 3s ease-out infinite 1.5s backwards;
}
#middle-top .plane {
transform: translate3d(0px, 0, 0);
background: #2358be;
animation: trans25 3s ease-out infinite 2s backwards;
}
#bottom .plane {
z-index: 2000;
animation: trans1 3s ease-out infinite 2.6s backwards;
}
#top {
width: 53px;
height: 20px;
left: 40px;
transform: skew(15deg, 0);
z-index: 100;
top: -26px;
}
#middle-top {
width: 33px;
height: 20px;
left: 60px;
top: -10px;
transform: skew(15deg, -45deg);
}
#middle {
width: 33px;
height: 20px;
left: 60px;
top: 15px;
transform: skew(-15deg, 40deg);
}
#bottom {
width: 53px;
height: 20px;
left: 40px;
top: 30px;
transform: skew(-15deg, 0);
}
#loading-texte {
color: white;
position: absolute;
top: 70px;
font-family: Arial;
text-align: center;
font-size: 12px;
}
#keyframes trans1 {
from {
transform: translate3d(-250px, 0, 0);
}
to {
transform: translate3d(53px, 0, 0);
}
}
#keyframes trans2 {
from {
transform: translate3d(33px, 0, 0);
}
to {
transform: translate3d(-250px, 0, 0);
}
}
#keyframes trans25 {
from {
transform: translate3d(-250px, 0, 0);
}
to {
transform: translate3d(33px, 0, 0);
}
}
#keyframes trans3 {
from {
transform: translate3d(53px, 0, 0);
}
to {
transform: translate3d(-250px, 0, 0);
}
}
<section id="global">
<div class="anim">
<div id="top" class="mask">
<div class="plane"></div>
</div>
<div id="middle-top" class="mask">
<div class="plane"></div>
</div>
<div id="middle" class="mask">
<div class="plane"></div>
</div>
<div id="bottom" class="mask">
<div class="plane"></div>
</div>
</div>
<p id="loading-texte"><i>LOADING...</i></p>
</section>
#global {
width: 70px;
margin: auto;
margin-top: 100px;
position: relative;
cursor: pointer;
height: 60px;
}
.mask {
position: absolute;
border-radius: 2px;
overflow: hidden;
perspective: 1000;
backface-visibility: hidden;
}
.anim {
transform: rotate(90deg);
}
#top {
width: 53px;
height: 20px;
left: 40px;
transform: skew(15deg, 0);
z-index: 100;
top: -26px;
}
#middle-top {
width: 33px;
height: 20px;
left: 60px;
top: -10px;
transform: skew(15deg, -45deg);
}
#middle {
width: 33px;
height: 20px;
left: 60px;
top: 15px;
transform: skew(-15deg, 40deg);
}
#bottom {
width: 53px;
height: 20px;
left: 40px;
top: 30px;
transform: skew(-15deg, 0);
}
.plane {
background: #2a6fed;
width: 100%;
height: 100%;
position: absolute;
z-index: 100;
perspective: 1000;
backface-visibility: hidden;
animation-direction: alternate;
animation-duration: 4s;
animation-iteration-count: infinite;
}
#bottom .plane {
z-index: 2000;
animation-name: trans1;
}
#middle .plane {
transform: translate3d(0, 0, 0);
background: #2358be;
animation-name: trans2;
}
#middle-top .plane {
transform: translate3d(0, 0, 0);
background: #2358be;
animation-name: trans3;
}
#top .plane {
transform: translate3d(0, 0, 0);
z-index: 2000;
animation-name: trans4;
}
#keyframes trans1 {
0% {
transform: translate3d(-100%, 0, 0);
}
25% {
transform: translate3d(0%, 0, 0);
}
100% {
transform: translate3d(0%, 0, 0);
}
}
#keyframes trans2 {
0% {
transform: translate3d(100%, 0, 0);
}
25% {
transform: translate3d(100%, 0, 0);
}
50% {
transform: translate3d(0%, 0, 0);
}
100% {
transform: translate3d(0%, 0, 0);
}
}
#keyframes trans3 {
0% {
transform: translate3d(-100%, 0, 0);
}
50% {
transform: translate3d(-100%, 0, 0);
}
75% {
transform: translate3d(0%, 0, 0);
}
100% {
transform: translate3d(0%, 0, 0);
}
}
#keyframes trans4 {
0% {
transform: translate3d(100%, 0, 0);
}
75% {
transform: translate3d(100%, 0, 0);
}
100% {
transform: translate3d(0%, 0, 0);
}
}
#loading-texte {
color: white;
position: absolute;
top: 70px;
font-family: Arial;
text-align: center;
font-size: 12px;
}
<section id="global">
<div class="anim">
<div id="top" class="mask">
<div class="plane"></div>
</div>
<div id="middle-top" class="mask">
<div class="plane"></div>
</div>
<div id="middle" class="mask">
<div class="plane"></div>
</div>
<div id="bottom" class="mask">
<div class="plane"></div>
</div>
</div>
<p id="loading-texte"><i>LOADING...</i></p>
</section>

Perfect infinite rotation for ֍ character

Im trying to use this character
֍
in place of a loading spinner.
Here's what I've got so far:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
font-size: 60px;
display: inline-block;
font-weight: normal;
transform-origin: 50% 50%;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Even though this works, it is not perfect because the rotation does currently not happen around the perfect center of the character despite
transform-origin: 50% 50%;
making it look less than stellar.
Any ideas how to fix this?
I would use a fixed height equal to the font-size then play with line-height until I get it right. Also no need to set transform-origin since by default it's set to center
.spinner::after {
content: "֍";
font-size: 60px;
font-weight: normal;
line-height: 0.8;
display: inline-block;
height: 60px;
animation: rotating 2s linear infinite;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
it happens because a character height and width are not equal...
I tried to increase the height until It does what you want..
and here is the result:
.spinner::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
Three Properties
line-height: 3;
transform-origin: 50% 54%;
text-align: center;
Demo
.spinner::after {
animation: spin 2s infinite linear;
content: "֍";
font-size: 5em;
display: inline-block;
font-weight: normal;
/* Required */
line-height: 3;
/* Required */
transform-origin: 50% 54%;
/* Required */
text-align: center;
/* Optional for Position */
position: relative;
width: 3em;
top: 0;
}
#keyframes spin {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
<i class="spinner"></i>
You will not get perfect center while rotating rectangle shape but you will get perfect center if its square shape
see demo below
div {
display: inline-block;
width: 100px;
height: 100px;
background-color: brown;
text-align: center;
position: relative;
margin: 10px;
float: left;
}
.spinner0::after {
animation: rotating 2s linear infinite;
content: "֍";
height: 80px;
font-size: 60px;
display: inline-block;
font-weight: normal;
}
#keyframes rotating {
0% {
transform: rotate(0deg) scale(1);
color: rgba(0, 0, 0, .5);
}
50% {
transform: rotate(180deg) scale(.8);
color: rgba(0, 0, 0, .85);
}
100% {
transform: rotate(360deg);
color: rgba(0, 0, 0, .5);
}
}
div > i:before {
content: '';
width: 5px;
height: 5px;
background-color: #000;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.spinner1::after{
animation: rotating 5s linear infinite;
content: "֍";
font-size: 60px;
line-height: 60px;
display: inline-block;
font-weight: normal;
position: absolute;
left: 50%;
top: 50%;
margin-top: -30px;
margin-left: -22px;
}
.spinner2::after {
animation: rotating 5s linear infinite;
content: "֍";
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
font-size: 60px;
transform: rotate(90deg);
margin-left: 2px;
}
.spinner3::after {
animation: rotating 5s linear infinite;
content: "";
height: 30px;
width: 30px;
font-size: 60px;
line-height: 1;
display: inline-block;
font-weight: normal;
border: 1px solid #000;
position: absolute;
left: 50%;
top: 50%;
margin-top: -15px;
margin-left: -15px;
}
<div>
<i class="spinner1"></i>
</div>
<div>
<i class="spinner2"></i>
</div>
<div>
<i class="spinner3"></i>
</div>
if you still want to rotate rectangular shape/icon then along with rotation you have to adjust its position a bit
hope you got my point here

How can I build a 3d inside room view in css?

There are already some nice posts on animating 3d objects in css. However I wondered whether it is possible to do so from the perspective of being inside the object.
This would be nice to build, for example, a pure css game or street view like application.
After some tweaking with the help of David DeSandro, this css did the trick.
#container {
top: 100px;
width: 1200px;
height: 600px;
position: relative;
perspective: 600px;
/* half the width */
border: 2px solid green;
}
#room {
width: 100%;
height: 100%;
position: absolute;
transform-origin: 50% 80% 600px;
transform-style: preserve-3d;
}
#room figure {
margin: 0;
display: block;
position: absolute;
border: 2px solid green;
font: 400px"calibri";
text-align: center;
}
#room .n,
.e,
.s,
.w {
width: 1196px;
height: 596px;
}
#room .n {
background-color: rgba(255, 0, 0, 0.3);
}
#room .e {
background-color: rgba(255, 255, 0, 0.3);
}
#room .s {
background-color: rgba(0, 255, 255, 0.3);
}
#room .w {
background-color: rgba(0, 0, 255, 0.3);
}
#room .t,
.b {
width: 1196px;
height: 1196px;
top: -300px;
background-color: rgba(200, 200, 200, 0.5);
}
/* transform & inverse */
#room .n {
transform: rotateY(0deg) translateZ(0px);
}
#room .e {
transform: rotateY(-90deg) translateZ(-600px) translateX(600px);
}
#room .s {
transform: rotateY(180deg) translateZ(-1200px);
}
#room .w {
transform: rotateY(90deg) translateZ(-600px) translateX(-600px);
}
#room .t {
transform: rotateX(90deg) translateZ(300px) translateY(600px);
}
#room .b {
transform: rotateX(90deg) translateZ(-300px) translateY(600px);
}
#room .show-n {
transform: translateZ(0px) rotateY(0deg);
}
#room .show-e {
transform: translateX(-600px) translateZ(600px) rotateY(90deg);
}
#room .show-s {
transform: translateZ(1200px) rotateY(180deg);
}
#room .show-w {
transform: translateX(600px) translateZ(600px) rotateY(-90deg);
}
#room .show-t {
transform: translateY(-600px) translateZ(-300px) rotateX(-90deg);
}
#room .show-b {
transform: translateY(-600px) translateZ(300px) rotateX(90deg);
}
#room {
animation: 5s hspinner;
}
#keyframes hspinner {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(-360deg);
}
}
<section id="container">
<div id="room">
<figure class="n">N</figure>
<figure class="e">O</figure>
<figure class="s">Z</figure>
<figure class="w">W</figure>
<figure class="t">T</figure>
<figure class="b">B</figure>
</div>
</section>
Enjoy.

Resources