I am trying to add an extra stage to a 4-step CSS progress indicator and make it a 5-step progress indicator. The existing code is shown below. How can I modify the code to achieve this?
.myact__progress-indicator {
position:relative;
width:34px;
height:34px;
border-radius:50%;
border:2px solid $twe-grey-lightest;
}
.myact__progress-indicator-progress {
position:absolute;
width:34px;
height:34px;
border-radius:17px;
clip:rect(0px, 34px, 34px, 17px);
margin:-2px;
&:before {
position:absolute;
display:block;
content:'';
width:34px;
height:34px;
background-color:$twe-green;
border-radius:17px;
clip:rect(0px, 17px, 34px, 0px);
transform:rotate(0deg);
}
&:after {
position:absolute;
display:block;
content:'';
width:34px;
height:34px;
background-color:$twe-green;
border-radius:17px;
clip:rect(17px, 34px, 34px, 17px);
transform:rotate(90deg);
}
&.p1 {
&:before {
transform:rotate(72deg);
}
}
&.p2 {
&:before {
transform:rotate(144deg);
}
}
&.p3 {
clip:rect(0px, 34px, 34px, 0px);
&:before {
transform:rotate(144deg);
}
&:after {
transform:rotate(90deg);
}
}
&.p4 {
clip:rect(0px, 34px, 34px, 0px);
&:before {
transform:rotate(216deg);
}
&:after {
transform:rotate(72deg);
}
}
&.p5 {
clip:rect(0px, 34px, 34px, 0px);
&:before {
clip:rect(0px, 34px, 34px, 0px);
transform:rotate(0deg);
}
&:after {
display:none;
}
}
}
HTML:
<div class="myact__progress-indicator">
<div class="myact__progress-indicator-progress p{{r.fields[6].value + 1}}"></div>
<div class="myact__progress-indicator-inner">
<span class="myact__progress-indicator-label">{{r.fields[6].value+1}}/5</span>
</div>
</div>
P1 and P2 are working as expected but it starts to fall over at P3, I tried to create a fiddle but I'm unable to replicate, I'm hoping I missed something glaringly obvious.
Related
I have a circle progress bar, only with HTML and CSS, I used keyframes for loading (animation). But the loading is from right to left I wanna reverse it. I edit my CSS keyframes but nothing at all. I try also animation reverse again nothing.
Fiddle:
https://jsfiddle.net/d20wu8e4/
My Result (image):
https://ibb.co/0KCSsZY
What I want:
https://ibb.co/MGCpHqS
* {
box-sizing:border-box;
}
.progress {
width: 150px;
height: 150px;
background: none;
margin: 0 auto;
box-shadow: none;
position: relative;
}
.progress:after {
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid #fff;
position: absolute;
top: 0;
left: 0;
opacity: 0.5;
}
.progress>span {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
}
.progress .progress-left {
left: 0;
}
.progress .progress-bar {
width: 100%;
height: 100%;
background: none;
border-width: 2px;
border-style: solid;
position: absolute;
top: 0;
}
.progress .progress-left .progress-bar {
left: 100%;
border-top-right-radius: 80px;
border-bottom-right-radius: 80px;
border-left: 0;
-webkit-transform-origin: center left;
transform-origin: center left;
}
.progress .progress-right {
right: 0;
}
.progress .progress-right .progress-bar {
left: -100%;
border-top-left-radius: 80px;
border-bottom-left-radius: 80px;
border-right: 0;
-webkit-transform-origin: center right;
transform-origin: center right;
animation: loading 1.8s linear forwards;
}
.progress .progress-value {
width: 79%;
height: 79%;
border-radius: 50%;
background: none;
font-size: 24px;
color: black;
line-height: 135px;
text-align: center;
position: absolute;
top: 5%;
left: 5%;
}
.progress.one .progress-bar {
border-color: black;
}
.progress.one .progress-left .progress-bar {
animation: loading-1 1s linear forwards 1.8s;
}
#keyframes loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
}
#keyframes loading-1 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
<div class="container bg-danger">
<div class="row mt-5">
<div class="progress one">
<span class="progress-left">
<span class="progress-bar"></span>
</span>
<span class="progress-right ">
<span class="progress-bar"></span>
</span>
<div class="progress-value">73%</div>
</div>
</div>
</div>
As I commented, the trivial solution is to rotate the whole animation:
* {
box-sizing:border-box;
}
.progress {
width: 150px;
height: 150px;
background: none;
margin: 0 auto;
box-shadow: none;
position: relative;
transform: scaleX(-1);
}
.progress-value {
transform: scaleX(-1);
}
.progress:after {
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid #fff;
position: absolute;
top: 0;
left: 0;
opacity: 0.5;
}
.progress>span {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
}
.progress .progress-left {
left: 0;
}
.progress .progress-bar {
width: 100%;
height: 100%;
background: none;
border-width: 2px;
border-style: solid;
position: absolute;
top: 0;
}
.progress .progress-left .progress-bar {
left: 100%;
border-top-right-radius: 80px;
border-bottom-right-radius: 80px;
border-left: 0;
-webkit-transform-origin: center left;
transform-origin: center left;
}
.progress .progress-right {
right: 0;
}
.progress .progress-right .progress-bar {
left: -100%;
border-top-left-radius: 80px;
border-bottom-left-radius: 80px;
border-right: 0;
-webkit-transform-origin: center right;
transform-origin: center right;
animation: loading 1.8s linear forwards;
}
.progress .progress-value {
width: 79%;
height: 79%;
border-radius: 50%;
background: none;
font-size: 24px;
color: black;
line-height: 135px;
text-align: center;
position: absolute;
top: 5%;
left: 5%;
}
.progress.one .progress-bar {
border-color: black;
}
.progress.one .progress-left .progress-bar {
animation: loading-1 1s linear forwards 1.8s;
}
#keyframes loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
}
#keyframes loading-1 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
<div class="progress one">
<span class="progress-left">
<span class="progress-bar"></span>
</span>
<span class="progress-right ">
<span class="progress-bar"></span>
</span>
<div class="progress-value">73%</div>
</div>
By the way here is another idea that rely on less code. The trick is to consider clip-path where you will adjust the position of the different points in order to create the needed animation
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 2s linear forwards;
}
#keyframes change {
25% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
50% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
75% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0, 0% 0%);
}
}
body {
background:pink;
}
<div class="box">
73%
</div>
To better understand the animation, add background and remove the radius. We basically have 6 points in the polygon where 2 are fixed (the center (50% 50%) and top one (0 0)) then we move the 4 others to put them in the corners. The trick is to move them together and we leave one at each corner (each state of the animation).
.box {
width:100px;
height:100px;
margin:50px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
background:rgba(0,0,0,0.5);
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
background:red;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 5s linear forwards;
}
#keyframes change {
25% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
50% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
75% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0, 0% 0%);
}
}
body {
background:pink;
}
<div class="box">
73%
</div>
With this code you have the full animation, simply adjust the final state or remove some states to stop it where you want.
Ex with 75% (we remove the last state)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 3s linear forwards;
}
#keyframes change {
33% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
66% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
}
body {
background:pink;
}
<div class="box">
75%
</div>
With 66% (we remove the last state and we change the percentage of the third one)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 2s linear forwards;
}
#keyframes change {
33% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
66% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 40%);
}
}
<div class="box">
75%
</div>
with 10% (only one state)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 1s linear forwards;
}
#keyframes change {
100% {
clip-path:polygon(50% 50%,0 0, 0 40%,0 40%,0 40%,0 40%);
}
}
body {
background:pink;
}
<div class="box">
10%
</div>
This progress works in new blink/webkit browsers since it uses conic-gradient(). In addition, to change the progress we use css variables, so animation will require JS.
The idea is to create a conic gradient of black to transparent, and change the degrees according to the progress. To get a line instead of a circle, I use an inner gradient from white to white, that doesn't cover the border (background-clip: content-box) as suggested by #TemaniAfif.
Play with the values of the input box to see the progress.
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(36)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border:5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(black var(--percentage,0), transparent var(--percentage,0)) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br />
Progress value: <input type="number" min="0" max="100" value="36">
And for the other direction (added by #TemaniAfif):
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(36)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border:5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(from calc(-1*var(--percentage)), black var(--percentage,0), transparent var(--percentage,0)) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br />
Progress value: <input type="number" min="0" max="100" value="36">
A variation on the same idea, is to create progress circle with multiple colors, and then hide it using a gradient from transparent to white. Make the transparent area bigger to expose the colored line.
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(80)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border: 5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(transparent var(--percentage, 0), white var(--percentage, 0)) border-box,
conic-gradient(green 120deg, yellow 120deg 240deg, red 240deg) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br /> Progress value: <input type="number" min="0" max="100" value="80">
I'm kind of new to CSS3 Animations and hope anybody out there could help me realising this.
I'm having a div with text in it. I would like to reveal this div from the center. It looks kind of simple, but until now I didn't find the perfect way to realise it.
Do I need to use
.text-div {
clip-path: inset(top right bottom left);
animate: revealText 3s;
}
#keyframes revealText {
0% {
clip-path: inset(top right bottom left);
},
100% {
clip-path: inset(top right bottom left);
}
}
or would you suggest another way to solve this?
Thanks for your help!
Cara
see here jsfiddle
i used : width:0% on the animation to hide the text , and added white-space:nowrap to initial state of the text so it doesn't go on two separate lines because of the width:0% and added overflow:hidden
play around with the css i gave you , remove some of the things to see how they work
css :
.text-div {
width:100%;
white-space:nowrap;
overflow:hidden;
animation: revealText 3s;
color:white;
text-align:center;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top:45%;
}
.content {
background:red;
height:200px;
width:200px;
position:relative;
}
#keyframes revealText {
0% {
width:0%;
}
100% {
width:100%;
}
}
EDIT you could use pseudo-elements like :before and :after , but this only if you have a background color underneath the text . like in this example red
see here : jsfiddle
css :
.text-div {
color:white;
text-align:center;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top:45%;
}
.text-div:before {
left:0;
}
.text-div:after {
right:0;
}
.text-div:after,.text-div:before {
position:absolute;
content:"";
height:100%;
width:50%;
background:red;
animation: revealText 3s;
}
.content {
background:red;
height:200px;
width:200px;
position:relative;
}
#keyframes revealText {
0% {
width:50%
}
100% {
width:0%
}
}
That's how I realised it in the end. It appears to me, that until now, there is no easier way to do this.
JSFiddle here
.text-div {
position: absolute;
top: 45%;
right: 0;
left: 0;
margin: 0 auto;
text-align: center;
color: white;
clip-path: inset(0px 50% 0px 50%);
-webkit-clip-path: inset(0px 50% 0px 50%);
animation: revealText 3s;
}
.content {
background:red;
height:200px;
width:200px;
position:relative;
}
#keyframes revealText {
0% {
clip-path: inset(0px 50% 0px 50%);
-webkit-clip-path: inset(0px 50% 0px 50%);
}
100% {
clip-path: inset(0px 0px 0px 0px);
-webkit-clip-path: inset(0px 0px 0px 0px);
}
}
Thanks everybody for input!
i want to seperate 2 floating div's with a slope line, they got different background colors.
Example here:
HTML markup:
<div id="wrap">
<div id="one"></div>
<div id="two"></div>
</div>
i allready tried to rotate them (as u can see in the jsFiddle):
#wrap div {
-moz-transform: rotate(20deg);
-ms-transform: rotate(20deg);
-o-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
float:left;
width:50%;
height:200px;
}
http://jsfiddle.net/F6DgA/
Also i tried smth. with overflow:hidden:
http://jsfiddle.net/F6DgA/1/ (partly corrent, but not very clean solution)
Is there a more easy way (dont wann use an image..)?
I would personally avoid using transforms and use the border property instead. This seems much cleaner to me (and also works in IE8).
Example: http://jsfiddle.net/F6DgA/5/
Note: To make sure the content inside the divs doesn't float on top of the edge, add something like * { box-sizing:border-box; } and then a padding left/right to the divs.
The CSS:
#wrap {
width:300px;
height:100px;
margin:0 auto;
position:relative;
}
#wrap div {
position:relative;
height:100%;
float:left;
}
#one {
background:#333;
width:calc(50% + 15px);
}
#one:after {
content:"";
position:absolute;
right:0;
border-right:30px solid black;
border-top:100px solid transparent;
}
#two {
background:#000;
width:calc(50% - 15px);
}
Use CSS gradient for the #wrap div, check here for an example.
Something like this:
background: #9dd53a;
background: -moz-linear-gradient(-45deg, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%);
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,#9dd53a), color-stop(50%,#a1d54f), color-stop(51%,#80c217), color-stop(100%,#7cbc0a));
background: -webkit-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
background: -o-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
background: -ms-linear-gradient(-45deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
background: linear-gradient(135deg, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a',GradientType=1 );
Whatever the height and width having your parent div you have to double height of your child element. After that give position:absolute to your child elements. Give -50% left position to your first child div and give -50% right position to your second child div
CSS Will be like following:
#wrap {
width:400px;
margin:0 auto;
position:relative;
height:300px;
overflow:hidden;
}
#wrap div {
-moz-transform: rotate(20deg);
-ms-transform: rotate(20deg);
-o-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
float:left;
width:100%;
height:600px;
top:-50%;
position:absolute;
}
#wrap div#one { left:-50%; }
#wrap div#two { right:-50%; }
#one {
background:#333;
}
#two {
background:#000;
}
Please check this Working URL
Demo
css
#one {
border-top: 200px solid gray;
border-right: 100px solid transparent;
height: 0;
width: 30%;
float:left
}
#two {
border-bottom: 200px solid black;
border-left: 100px solid transparent;
height: 0;
width: 30%;
float:left;
margin-left:-100px;
}
#wrap {
width:400px;
margin:0 auto;
}
you can use pseudo element :after or :before
CODEPEN
<div class="rect"></div>
.rect {
background:#000;
height: 50px;
width: 150px;
position: relative;
overflow: hidden;
}
.rect:after {
content: "";
background:#333;
height: 100px;
width: 300px;
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
display: block;
position: absolute;
top:-7px;
right: 10px;
}
Reference this css Shape examples !
This is what I've tried . Demo here !
It's not correctly the same with your need .
But I think , you can approach your need by a little modification !
html
<div Id="parallelogram"></div>
<div Id="parallelogram2"></div>
css
#parallelogram {
width: 130px;
height: 75px;
background: pink;
position:absolute;
overflow:hidden;
/* Skew */
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-o-transform: skew(-20deg);
transform: skew(-20deg);
}
#parallelogram2 {
width: 130px;
height: 75px;
margin-left:100px;
background: Black;
position:absolute;
overflow:hidden;
/* Skew */
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-o-transform: skew(-20deg);
transform: skew(-20deg);
}
After much Googling and fiddling with various different options, I'm struggling to get my CSS3 Animation to behave in the way I want it to!
Let me start with the code
<html>
<head>
<style>
body
{
overflow:hidden;
margin:0px;
}
.about
{
overflow:hidden;
width:400%;
height:95%;
background:#10b4ff;
position:absolute;
animation-name:contentPane;
animation-duration:5s;
animation-timing-function:ease;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:running;
/* Safari and Chrome: */
-webkit-animation-name:contentPane;
-webkit-animation-duration:5s;
-webkit-animation-timing-function:ease;
-webkit-animation-delay:0s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
}
#keyframes contentPane
{
0% {background:#eeeeee; left:0px; top:0px;}
33% {background:#10b4ff; left:-100%; top:0px;}
66% {background:#eeeeee; left:-200%; top:0px;}
100% {background:#10b4ff; left:-300%; top:0px;}
}
#-webkit-keyframes contentPane
{
0% {background:#eeeeee; left:0px; top:0px;}
33% {background:#10b4ff; left:-100%; top:0px;}
66% {background:#eeeeee; left:-200%; top:0px;}
100% {background:#10b4ff; left:-300%; top:0px;}
}
.menuMarker{
width:20px;
height:20px;
border:2px solid #fff;
background:#fff;
border-radius:50%;
bottom:7%;
position:absolute;
/* Animation */
animation-name:menuMarker;
animation-duration:5s;
animation-timing-function:ease;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:running;
/* Safari and Chrome: */
-webkit-animation-name:menuMarker;
-webkit-animation-duration:5s;
-webkit-animation-timing-function:ease;
-webkit-animation-delay:0s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
}
#keyframes menuMarker
{
0% {background:#10b4ff; border:#eeeeee 2px solid; border-radius:50%; left:12.5%;}
33% {background:#eeeeee; border:#10b4ff 2px solid; border-radius:30%; left:37.5%;}
66% {background:#10b4ff; border:#eeeeee 2px solid; border-radius:50%; left:62.5%;}
100% {background:#eeeeee; border:#10b4ff 2px solid; border-radius:30%; left:87.5%;}
}
#-webkit-keyframes menuMarker
{
0% {background:#10b4ff; border:#eeeeee 2px solid; border-radius:50%; left:12.5%;}
33% {background:#eeeeee; border:#10b4ff 2px solid; border-radius:30%; left:37.5%;}
66% {background:#10b4ff; border:#eeeeee 2px solid; border-radius:50%; left:62.5%;}
100% {background:#eeeeee; border:#10b4ff 2px solid; border-radius:30%; left:87.5%;}
}
.one{
width:25%;
height:100%;
left:0px;
top:0px;
position:absolute;
color:#10b4ff;
}
.two{
width:25%;
height:100%;
left:25%;
top:0px;
position:absolute;
color:#eeeeee;
}
.three{
width:25%;
height:100%;
left:50%;
top:0px;
position:absolute;
color:#10b4ff;
}
.four{
width:25%;
height:100%;
left:75%;
top:0px;
position:absolute;
color:#eeeeee;
}
.menuOne{
border-top:2px #fff solid;
left:0%;
width:25%;
height:5%;
bottom:0px;
background:#10b4ff;
position:fixed;
}
.menuTwo{
border-top:2px #fff solid;
left:25%;
width:25%;
height:5%;
bottom:0px;
background:#eeeeee;
position:fixed;
}
.menuThree{
border-top:2px #fff solid;
left:50%;
width:25%;
height:5%;
bottom:0px;
background:#10b4ff;
position:fixed;
}
.menuFour{
border-top:2px #fff solid;
left:75%;
width:25%;
height:5%;
bottom:0px;
background:#eeeeee;
position:fixed;
}
</style>
</head>
<body>
<div class='about'>
<div class='one'>Test 1</div>
<div class='two'>Test 2</div>
<div class='three'>Test 3</div>
<div class='four'>Test 4</div>
</div>
<div class='menuMarker'></div>
<div class='menuOne'><center>About</center></div>
<div class='menuTwo'>Gallery</div>
<div class='menuThree'>Showreel</div>
<div class='menuFour'>Contact</div>
</body>
</html>
So here's the thing. I tried to add make all the animation-play-state properties "paused" and then add:
menuOne:hover
{
animation-name:menuMarker;
animation-play-state:running;
}
Problem is, this predictably makes the menuOne class behave as if it's the marker. What I'm looking for is a way of hovering over the different menu items (menuOne, menuTwo etc) and have the marker move to it's position over that item.
Am at a complete loss, and would LOVE some help!
Thanks guys and gals!
First, don't use center tags. There are much better ways to position things in the middle, in your case that would be giving the menus text-align:center;
The closest you can get using your pure CSS animation is something like this, where the animations pause when the menu is hovered over. Your animation runs in a loop, and currently in CSS3 you're not allowed to restart the animation at a different point, so you can't do it well.
That being said, you can add simple transitions ALONG with your animation and get a much more desirable result like this one! It has some glitches, but you can likely play around with it to get a little bit smoother. But again, since CSS3 does not allow animations to be started mid-animation, it won't be perfect. If you used javascript as well it could be done a fair bit smoother, but you didn't mention that in your question
Here is the updated CSS and slightly modified HTML
<html>
<head>
<style>
body {
overflow:hidden;
margin:0px;
}
.about {
overflow:hidden;
width:400%;
height:95%;
background:#10b4ff;
position:absolute;
animation-name:contentPane;
animation-duration:15s;
animation-timing-function:ease;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:running;
/* Safari and Chrome: */
-webkit-animation-name:contentPane;
-webkit-animation-duration:15s;
-webkit-animation-timing-function:ease;
-webkit-animation-delay:0s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
transition: all .5s linear;
-webkit-transition: all .5s linear;
}
#keyframes contentPane {
0% {
background:#eeeeee;
left:0px;
}
33% {
background:#10b4ff;
left:-100%;
}
66% {
background:#eeeeee;
left:-200%;
}
100% {
background:#10b4ff;
left:-300%;
}
}
#-webkit-keyframes contentPane {
0% {
background:#eeeeee;
left:0px;
}
33% {
background:#10b4ff;
left:-100%;
}
66% {
background:#eeeeee;
left:-200%;
}
100% {
background:#10b4ff;
left:-300%;
}
}
.menuMarker {
width:20px;
height:20px;
border:2px solid #fff;
background:#fff;
border-radius:50%;
bottom:7%;
position:absolute;
/* Animation */
animation-name:menuMarker;
animation-duration:15s;
animation-timing-function:ease;
animation-delay:0s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:running;
/* Safari and Chrome: */
-webkit-animation-name:menuMarker;
-webkit-animation-duration:15s;
-webkit-animation-timing-function:ease;
-webkit-animation-delay:0s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
transition: all .5s linear;
-webkit-transition: all .5s linear;
}
#keyframes menuMarker {
0% {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:12.5%;
}
33% {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:37.5%;
}
66% {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:62.5%;
}
100% {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:87.5%;
}
}
#-webkit-keyframes menuMarker {
0% {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:12.5%;
}
33% {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:37.5%;
}
66% {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:62.5%;
}
100% {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:87.5%;
}
}
.one {
width:25%;
height:100%;
left:0;
top:0;
position:absolute;
color:#10b4ff;
}
.two {
width:25%;
height:100%;
left:25%;
top:0;
position:absolute;
color:#eeeeee;
}
.three {
width:25%;
height:100%;
left:50%;
top:0;
position:absolute;
color:#10b4ff;
}
.four {
width:25%;
height:100%;
left:75%;
top:0;
position:absolute;
color:#eeeeee;
}
.menu {
position:absolute;
bottom:0;
text-align:center;
width:25%;
height:5%;
background:#10b4ff;
}
.menuOne {
left:0;
}
.menuTwo {
left:25%;
}
.menuThree {
left:50%;
}
.menuFour {
left:75%;
}
.menu:nth-child(even) {
background:#eeeeee;
}
.menu:hover ~ .menuMarker {
animation:none;
-webkit-animation: none;
}
.menu:hover ~ .about {
animation: none;
-webkit-animation:none;
}
.menuOne:hover ~ .about {
background:#eeeeee;
left:0px;
}
.menuTwo:hover ~ .about {
background:#10b4ff;;
left:-100%;
}
.menuThree:hover ~ .about {
background:#eeeeee;
left:-200%;
}
.menuFour:hover ~ .about {
background:#10b4ff;
left:-300%;
}
.menuOne:hover ~ .menuMarker {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:12.5%;
}
.menuTwo:hover ~ .menuMarker {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:37.5%;
}
.menuThree:hover ~ .menuMarker {
background:#10b4ff;
border:#eeeeee 2px solid;
border-radius:50%;
left:62.5%;
}
.menuFour:hover ~ .menuMarker {
background:#eeeeee;
border:#10b4ff 2px solid;
border-radius:30%;
left:87.5%;
}
</style>
</head>
<body>
<div class='menu menuOne'>About</div><!--
--><div class='menu menuTwo'>Gallery</div><!--
--><div class='menu menuThree'>Showreel</div><!--
--><div class='menu menuFour'>Contact</div>
<div class='about'>
<div class='one'>Test 1 </div>
<div class='two'>Test 2</div>
<div class='three'>Test 3</div>
<div class='four'>Test 4</div>
</div>
<div class='menuMarker'></div>
</body>
</html>
I changed your HTML structure because you use position:absolute anyway and it made selecting the .about and .menuMarker easier
Side note: You don't have to declare the same top:0px; for your animations. If you don't tell it to change it won't. Also in CSS if you have a pixel value of 0 you can leave it off if you'd like, aka top:0 = top:0px
If you have any questions let me know!
I am trying to create a scissor effect in mootools, till now I have been able to achieve half of the effect.
index.html
window.addEvent('domready', function() {
events = [{transform: ['rotate(0deg) scale(1, 0) skew(0, 3deg) translate(100px, 50px)', 'rotate(180deg) scale(1.5, 4) skew(0, 3deg) translate(20px, 3px)']},
{transform: 'rotate(90deg) scale(1, 1) skew(0,0) translate(100, 100)'},
{transform: 'rotate(-10deg)'},
{transform: 'rotate(0)'},
{transform: 'rotate(90deg) scale(1, 1) skew(0,0) translate(100, 100)'},
{transform: 'rotate(10deg)'},
{transform: 'rotate(0deg)'}
];
$('triangle').addEvent('mouseenter', function(){
document.getElements('.down-triangle').each(function (el) {
el.set('tween', {duration: 1000, link: 'chain'}).addEvent('domready', function () {
this.get('tween').cancel().
start('transform', 'rotate(0)', events[2].transform).
start('transform', events[3].transform).s
})
})
document.getElements('.up-triangle').each(function (el) {
el.set('tween', {duration: 1000, link: 'chain' }).addEvent('domready', function () {
this.get('tween').cancel().
start('transform', 'rotate(0)', events[5].transform).
start('transform', events[6].transform).s
})
})
});
});
</script>
</head>
<body>
<div id="up">
<div id="bluebox" class="bluebox">
<div class="noshow">
<p>Need a website? </p>
</div>
</div>
</div>
<div id="bluebox1" class="bluebox1">
</div>
<div id="triangle" style="position:fixed;" >
<div id="up-triangle" class="up-triangle"></div>
<div id="down-triangle" class="down-triangle"></div>
</div>
</body>
style.css
#bluebox {
height:200px;
width:200px;
border:12px solid #000;
border-radius:500px;
margin-top:100px;
margin-left:800px;
-webkit-transition: -webkit-transform 550ms;
-moz-transition:-moz-transform 550ms;
transition: transform 550ms;
cursor:pointer;
}
.noshow{display: none; color:#fff;}
#bluebox:hover{
height:200px;
width:200px;
background:black;
-webkit-transform: scale(1.4);
-moz-transition:scale(1.4);
transform: scale(1.4);
z-index:20;
}
#bluebox:hover .noshow{display:inline;}
#bluebox1 {
height:200px;
width:200px;
border:12px solid #000;
border-radius:500px;
margin-top:0px;
margin-left:800px;
-webkit-transition: -webkit-transform 550ms;
-moz-transition:-moz-transform 550ms;
transition: transform 550ms;
cursor:pointer;
}
#bluebox1:hover{
height:200px;
width:200px;
background:#000;
-webkit-transform: scale(1.4);
-moz-transition:scale(1.4);
transform: scale(1.4);
}
#triangle{
width: 1px;
height: 1px;
}
#up-triangle {
width: 0px;
height: 0px;
border-bottom: 120px solid black;
border-left: 300px solid transparent;
border-right: 300px solid transparent;
margin-top:-345px;
margin-left:300px;
cursor:pointer;
}
#down-triangle {
width: 0;
height: 0;
border-top: 120px solid black;
border-left: 300px solid transparent;
border-right: 300px solid transparent;
margin-left:300px;
margin-top:2px;cursor:pointer;
}
The effect achieved is both the triangles moving up and down. But I want to make the circle move up and down along with the triangle.
I'd like to achieve that effect. How can I do that?