.LESS how to add width with duration? - html

I'm trying to create a loading bar, which will go longer on width with duration, with .less and here's my layout:
<section class="home-page container">
<div class="home-content col span_8_of_8">
<div class="preloader-1">
<em class="loader"></em>
</div>
</div>
</section>
The LESS part is here:
div.preloader-1 {
width: 100%;
border-radius: 1px;
border: thin solid #d5d5d5;
em.loader {
background: #main-red;
width: #preload_width;
.addBar('width', 5s);
}
}
#body-font: 'Droid Sans', sans-serif;
#heading-font: 'Oswald', sans-serif;
#flash-red: #ff0000;
#flash-green: #40bc88;
#main-green: #40bc88;
/* preloader 1 settings */
#preload_width: 10%;
#preloader1_class: 'preloader-1';
.addBar(#property, #duration, #style:ease-in-out) when(#preload_width <= 100%) {
-webkit-transition-property: #property;
-webkit-transition-duration: #duration;
-webkit-transition-timing-function: #style;
-moz-transition-property: #property;
-moz-transition-duration: #duration;
-moz-transition-timing-function: #style;
-ms-transition-property: #property;
-ms-transition-duration: #duration;
-ms-transition-timing-function: #style;
-o-transition-property: #property;
-o-transition-duration: #duration;
-o-transition-timing-function: #style;
transition-property: #property;
transition-duration: #duration;
transition-timing-function: #style;
#preload_width: (#preload_width + 10%);
}
Error came out like this:
>> SyntaxError: Recursive variable definition for #preload_width in app\assets\s
tylesheets\less\front\preloader_1.less on line 9, column 3:
>> 8 width: #preload-width;
>> 9 .addBar('width', 5s);
>> 10 }
I'm guessing it's on the whenpart in the less, but i'm not sure how to fix, can anyone explain to me how to do it? Thanks. (Oh yeah, the solution must not include JS or anything else, only pure .less)

Well, the problem is really here:
#preload_width: (#preload_width + 10%);
LESS can't handle variable redefinitions (e.g. changing a variable's value)
You're trying to create a variable with its own value.
Both of these problems can be solved by changing your new variable's name.

Related

How to transition out?

For the following code, the animation on hover works fine. Once I move away, it snaps back to the original size. How do I implement a transition on loss of focus so that there is animation into the div and out?
<style>
.border {
border:1px solid black;
width:500px;
}
.changesize:hover{
width:250px;
transition-property: width;
transition-duration: 1000ms;
transition-timing-function: ease-in;
}
</style>
<div class="border changesize">-- a div --</div>
http://scratchpad.io/caring-bead-826
Add following style (for .changesize when not hovered)
.changesize {
transition-property: width;
transition-duration: 1000ms;
transition-timing-function: ease-in;
}

How to delay one transition but not the other?

I have two transitions set for #circle.
I want only the opacity to have a delay, but I can only make it where both of the transitions do.
My full goal is to make the opacity change when the circle is mid spin (so at exactly 90deg).
But I will work out the timing myself, I just want to know how to give the delay to only one transition.
#circle {
background-color:black;
background-image:url('rain.img');
height:300px;
width:300px;
border-radius:100%;
margin:0 auto;
perspective:1000;
transition:transform 2s, opacity .1s;
}
#circle:hover {
perspective:1000px;
transform:rotateY(180deg);
opacity:.25;
}
I imagine you will only need to see the CSS, but if you think you need to see the full code go here ===> https://jsfiddle.net/z49kd9qk/
Any help would be appreciated, thanks!
Solution
The transition-delay function can only be parsed as the second timing value.
Instead of this:
transition: transform 2s, opacity .1s;
Work with this:
transition: transform 2s 0s, opacity 0s 2s;
Explanation
When working with the transition shorthand property, the order and presence of components matter. Here's the basic order and composition:
<transition-property> <transition-duration> <transition-timing-function> <transition-delay>
If the transition-property component is left out, the shorthand property applies all.
If the transition-timing-function component is left out, the shorthand applies ease.
(Both are the initial values of the respective properties.)
So you can minimize the declaration to this:
<transition-duration> <transition-delay>
If only one value is declared (like in your code), it will always be applied to transition-duration.
So with this:
transition: transform 2s, opacity .1s;
... you're applying a timing duration to both properties.
The transition-delay function can only be parsed as the second timing value.
Per your question:
I want only the opacity to have a delay but I can only make it where both of the transitions do.
Then do this instead:
transition: transform 2s 0s, opacity 0s 2s;
revised fiddle
#circle {
background-color: black;
background-image: url('https://media.giphy.com/media/eNMHeFodYv8Os/giphy.gif');
height: 300px;
width: 300px;
border-radius: 100%;
margin: 0 auto;
perspective: 1000;
/* transition:transform 2s, opacity .1s; */
transition: transform 2s 0s, opacity 0s 2s;
}
#circle:hover {
perspective: 1000px;
transform: rotateY(180deg);
opacity: .25;
}
#cloud {
height: 70px;
padding: 10px;
position: relative;
left: 10%;
top: 105px;
}
#temp {
font-family: 'Slabo 27px', serif;
position: relative;
left: 45%;
font-size: 100px;
bottom: 100px;
color: white;
}
<div id='circle'>
<img src='http://www.freeiconspng.com/uploads/rain-cloud-icon-5.png' id='cloud'>
<h2 id='temp'>54°</h2>
</div>

How to spin the logo 360 degrees using CSS?

I am working on a website and want to spin the logo 360 degrees. The website URL is http://flipped.in/JSJ/
The example code i am using is:
.rotate{
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow:hidden;
}
.rotate:hover
{
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
}
Now, i tried replacing the class 'rotate' with the one my logo has but it does not work. Can someone help me adding the right class to this?
The code works as such on Chrome and Firefox. It does not work on IE, since IE implements (in modern versions) the standard names for the properties involved, and the code lacks a setting for the transform property under its standard name. Adding it makes the code work on modern browsers.
<style>
.rotate{
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow:hidden;
}
.rotate:hover
{
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
transform:rotate(360deg); /* This was missing. */
}
</style>
<img class=rotate src=
"http://flipped.in/JSJ/wp-content/uploads/2014/12/JSJ-Logo.png"
alt="Jump Start Jonny">

Transitions - Can't get span to both rotate and change margin-top value

I'm trying to make a span rotate by 90° and to change margin-top on hover, but failing.
The span does rotate, but doesn't change its margin-top.
HTML
<div class="cheersWrapper">
<span class="cheers">
<h1>Hi!</h1>
</span>
<span class="smile">
<h1> :)</h1>
</span>
</div>
CSS
.cheersWrapper{
-webkit-transition-duration: 5s;
-moz-transition-duration: 5s;
-o-transition-duration: 5s;
transition-duration: 5s;
}
.cheersWrapper .smile {
display: none;
position: relative;
}
.cheersWrapper:hover .smile {
display: inline-block;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
transition: margin-top .5s;
-webkit-transition: margin-top;
-moz-transition: margin-top .5s;
-o-transition: margin-top .5s;
}
.cheersWrapper:hover .smile:hover{
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-o-transform:rotate(90deg);
margin-top:-25px;
}
.cheersWrapper .cheers{
display: inline-block;
}
Demo: http://jsfiddle.net/vmrq7ep7/3/
It looks like it has a sort of a Parkinson syndrome and it's stuck.
How can I make it animate its margin top?
Thanks in advance for your help.
You can use a css translate instead of margin for the .cheersWrapper:hover .smile:hover class:
transform:rotate(90deg) translate(0,-25px);
Then for the .cheersWrapper:hover .smile class set:
transition-property: transform;
Edited jsfiddle: http://jsfiddle.net/vmrq7ep7/4/
btw you should only need the -webkit- prefix and -ms- for IE9.

CSS3 Simultaneous Image Rotation, Scaling, animating and Opacity reduction

I wanted to create a Metro Style Website and want to add Buttons like in the following :
http://themeforest.net/item/metro-lab-responsive-metro-dashboard-template/full_screen_preview/5359122
When we hover over the 'New User', 'Sales' etc Tabs, the icons/Images in the tabs rotates, increases its size and looses opacity.
But I am not able to get the exact output. I get only 2 outputs at a time :
--> Opacity and Scaling
--> Opacity and Rotation
but not all of them simultaneously.
You can see where I had reached at :
http://developer.nuevothoughts.com/jiteen/attendance/docs/#
My Current CSS is :
.icon-rocket{
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-o-transition-property: -o-transform;
transition-property: transform;
overflow:hidden;
}
.icon-rocket:hover
{
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
/******************************/
-webkit-transform: scale(2.5,2.5);
-moz-transform:scale(2.5,2.5);
opacity: 0.5;
-moz-opacity: 0.5;
}
I would appreciate any kind of Help in this.
add following code
.main_tab.shortcut.span2.padding20.text-center a:hover i {
font-size: 40px;
opacity: 0.5;
transform: rotate(45deg);
}
and remove the hover you used (icon-rocket:hover)