`Hi, My nav bar wont show up in my project. The only thing that shows is the background color. Can anyone help me understand what i am doing wrong? I guess i need to conect it to an icon somehow - but how would that work? i appriciate all suggestions. I can also post the CSS file if needed.
JS:
this is the nav bar and some JS that is suppose to open it up when you press the the icon
import './test.scss';
import {Link} from "react-router-dom";
export function Header () {
//Js
console.clear();
const app = (() => {
let body;
let menu;
let menuItems;
const init = () => {
body = document.querySelector('body');
menu = document.querySelector('.menu-icon');
menuItems = document.querySelectorAll('.nav__list-item');
applyListeners();
}
const applyListeners = () => {
menu.addEventListener('click', () => toggleClass(body, 'nav-active'));
}
const toggleClass = (element, stringClass) => {
if(element.classList.contains(stringClass))
element.classList.remove(stringClass);
else
element.classList.add(stringClass);
}
init();
})();
return (
<>
<div className="menu-icon">
<span className="menu-icon__line menu-icon__line-left" />
<span className="menu-icon__line" />
<span className="menu-icon__line menu-icon__line-right" />
</div>
<div className="nav">
<div className="nav__content">
<ul className="nav__list">
<li className="nav__list-item">Home</li>
<li className="nav__list-item"></li>
<li className="nav__list-item"></li>
<li className="nav__list-item"></li>
</ul>
</div>
</div>
<div className="site-content">
<h1 className="site-content__headline">
text
</h1>
</div>
</>
);
}
thanks
CSS(SCSS) file:
$background--color:#1e2023;
$icon--color:#1e2023;
$font--color:#ffffff;
$font--color--active:#000000;
$font--primary:'Fira Sans', sans-serif;
$transition--length: .8;
body{
background-color: $background--color;
font-family: $font--primary;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.site-content{
max-width: 1100px;
height: 100vh;
margin-left: auto;
margin-right: auto;
display: flex;
align-items: center;
justify-content: center;
&__headline{
font-weight: 200;
color: $font--color;
font-size: calc(2vw + 10px);
text-align: center;
}
}
//default state
.menu-icon{
$size: 30px;
height: $size;
width: $size;
position: fixed;
z-index:2;
left: 50px;
top: 30px;
cursor: pointer;
&__line{
height: 2px;
width: $size;
display: block;
background-color: $font--color;
margin-bottom: 4px;
transition: transform .2s ease, background-color .5s ease;
}
&__line-left{
width: $size / 2;
}
&__line-right{
width: $size / 2;
float: right;
}
}
.nav{
$width: 100vw;
$height: 100vh;
$font--size--calc: calc(2vw + 10px);
$transition--easing: cubic-bezier(.77,0,.175,1);
position: fixed;
z-index:1;
&:before,&:after{
content: "";
position: fixed;
width:$width;
height:$height;
background: rgba(#eaeaea, .2);
z-index: -1;
transition: transform $transition--easing $transition--length + s;
transform: translateX(0%) translateY(-100%);
}
&:after{
background: rgba(#ffffff, 1);
transition-delay: 0s;
}
&:before{
transition-delay: .1s;
}
&__content{
position: fixed;
top:50%;
transform: translate(0%,-50%);
width: 100%;
text-align: center;
font-size: $font--size--calc;
font-weight: 200;
cursor: pointer;
}
&__list-item{
position: relative;
display: inline-block;
transition-delay: $transition--length + s;
opacity: 0;
transform: translate(0%, 100%);
transition: opacity .2s ease, transform .3s ease;
margin-right: 25px;
&:before{
content: "";
position: absolute;
background: $font--color--active;
width: 20px;
height: 1px;
top: 100%;
transform: translate(0%, 0%);
transition: all .3s ease;
z-index: -1;
}
&:hover{
&:before{
width: 100%;
}
}
}
}
//active state
body.nav-active{
$menu--items--count: 4;
.menu-icon{
&__line{
background-color: #000;
transform: translateX(0px) rotate(-45deg);
}
&__line-left{
transform: translateX(1px) rotate(45deg);
}
&__line-right{
transform: translateX(-2px) rotate(45deg);
}
}
.nav{
visibility:visible;
&:before,&:after{
transform: translateX(0%) translateY(0%);
}
&:after{
transition-delay: .1s;
}
&:before{
transition-delay: 0s;
}
&__list-item{
opacity: 1;
transform: translateX(0%);
transition: opacity .3s ease, transform .3s ease, color .3s ease;
#for $i from 0 through $menu--items--count {
&:nth-child(#{$i}){
transition-delay: $transition--length * $i / 8 + .5 + s;
}
}
}
}
}
Related
i would like to play this hover animation on component load, because I wrote a JS function that checks if the component is in the viewport and reloads it (changes its class).
You can use Sass (scss) or regular css.
.module .active {
display: inline-block;
position: relative;
color: var(--text-color-dark);
animation: loadInAnimation ease 3s;
animation-iteration-count: 1;
animation-fill-mode: forwards;
}
#keyframes loadInAnimation { // add :hover and :hover:after event
0% {
// start of animation
}
100% {
// end ofanimation
}
}
.module .active:after { // transform into keyframe animation
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 2px;
bottom: 0;
left: 0;
background-color: var(--primary-color);
transform-origin: bottom right;
transition: transform 0.25s ease-out;
}
.module .active:hover:after { // transform into keyframe animation
transform: scaleX(1);
transform-origin: bottom left;
}
Thank you for your help!
JS (irrelevant):
<script>
function reveal() {
var reveals = document.querySelectorAll(".reveal");
console.log(reveals);
for (var i = 0; i < reveals.length; i++) {
var windowHeight = window.innerHeight;
var elementTop = reveals[i].getBoundingClientRect().top;
var elementVisible = 150;
if (elementTop < windowHeight - elementVisible) {
reveals[i].classList.add("active");
} else {
reveals[i].classList.remove("active");
}
}
}
window.addEventListener("scroll", reveal);
window.addEventListener("load", reveal);
</script>
HTML (also irrelevant):
<h2 className='heading reveal'>Tennisakademie Vasquez</h2>
I've fixed the animation with an additional element providing the :after feature:
.module .heading {
font-size: 2.75rem;
font-weight: 700;
margin-bottom: 2rem;
font-family: 'Oswald', sans-serif;
font-weight: 200;
color: var(--text-color-dark);
}
.module .active {
display: inline-block;
position: relative;
color: var(--text-color-dark);
animation-iteration-count: 1;
animation-fill-mode: forwards;
.reveal-line {
transform: scaleX(1);
transform-origin: bottom left;
content: '';
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: var(--primary-color);
transform-origin: bottom right;
transition: transform 0.6s ease-out;
animation: loadInAnimation ease 1.5s;
}
}
#keyframes loadInAnimation {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<h3 className='heading reveal'>Unsere Angebote<div className='reveal-line' /></h3>
I'm attempting to create a carousel that rotates items in a upper circle / arc fashion.
This is how it's supposed to roll: https://thumbs.gfycat.com/HastyTemptingBarnswallow-mobile.mp4
My initial thought is to have 1 element in the middle then one previous and next which are slightly rotated. Upon dragging it should move all items along the x-axis and slightly rotate. This is my attempt:
https://codesandbox.io/s/muddy-cdn-rbs34?from-embed
Problem is I can't seem to make the dragging animation very smooth. I might also just be overthinking this and go in the wrong direction. Any advice?
I used the following link to create an effect like the one you want
https://tympanus.net/codrops/2013/08/09/building-a-circular-navigation-with-css-transforms/
You will have to adjust the CSS according to your UI.
$('.opened-nav li').click(function(event) {
var index = $(".opened-nav li").index(this);
console.log(index)
if (index >= 7) {
return;
}
let startDeg = 80;
$('#cn-wrapper').css({
'-webkit-transform': 'scale(2) rotate(' + (startDeg - (index) * 40) + 'deg)',
'-moz-transform': 'scale(2) rotate(' + (startDeg - (index) * 40) + 'deg)',
'-ms-transform': 'scale(2) rotate(' + (startDeg - (index) * 40) + 'deg)',
'-o-transform': 'scale(2) rotate(' + (startDeg - (index) * 40) + 'deg)',
'transform': 'scale(2) rotate(' + (startDeg - (index) * 40) + 'deg)'
});
/* console.log(event) */
})
#import url(http://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css);
* {
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
list-style: none;
position: relative
}
html,
body {
height: 100%;
}
body {
background: #f06060;
color: #fff;
}
.csstransforms .cn-wrapper {
font-size: 1em;
width: 26em;
height: 26em;
overflow: hidden;
position: fixed;
z-index: 10;
bottom: -20em;
left: 50%;
border-radius: 50%;
margin-left: -13em;
-webkit-transform: scale(0.1) rotate(40deg);
-ms-transform: scale(0.1) rotate(40deg);
-moz-transform: scale(0.1) rotate(40deg);
transform: scale(0.1) rotate(40deg);
pointer-events: none;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
}
.csstransforms .opened-nav {
border-radius: 50%;
pointer-events: auto;
-webkit-transform: scale(2) rotate(-40deg);
-moz-transform: scale(2) rotate(-40deg);
-ms-transform: scale(2) rotate(-40deg);
transform: scale(2) rotate(-40deg);
}
.cn-overlay {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
opacity: 0;
visibility: hidden;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
transition: all .3s ease;
z-index: 2;
}
.cn-overlay.on-overlay {
visibility: visible;
opacity: 1;
}
.cn-button {
border: none;
background: none;
color: #f06060;
text-align: center;
font-size: 1.8em;
padding-bottom: 1em;
height: 3.5em;
width: 3.5em;
background-color: #fff;
position: fixed;
left: 50%;
margin-left: -1.75em;
bottom: -1.75em;
border-radius: 50%;
cursor: pointer;
z-index: 11;
}
.cn-button:hover,
.cn-button:active,
.cn-button:focus {
color: #aa1010;
}
.csstransforms .cn-wrapper li {
position: absolute;
font-size: 1.5em;
width: 10em;
height: 10em;
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
transform-origin: 100% 100%;
overflow: hidden;
left: 50%;
top: 50%;
margin-top: -1.3em;
margin-left: -10em;
-webkit-transition: border .3s ease;
-moz-transition: border .3s ease;
transition: border .3s ease;
}
.csstransforms .cn-wrapper li a {
display: block;
font-size: 1.18em;
height: 14.5em;
width: 14.5em;
position: absolute;
bottom: -7.25em;
right: -7.25em;
border-radius: 50%;
text-decoration: none;
color: #fff;
padding-top: 1.8em;
text-align: center;
-webkit-transform: skew(-50deg) rotate(-70deg) scale(1);
-ms-transform: skew(-50deg) rotate(-70deg) scale(1);
-moz-transform: skew(-50deg) rotate(-70deg) scale(1);
transform: skew(-50deg) rotate(-70deg) scale(1);
-webkit-backface-visibility: hidden;
-webkit-transition: opacity 0.3s, color 0.3s;
-moz-transition: opacity 0.3s, color 0.3s;
transition: opacity 0.3s, color 0.3s;
}
.csstransforms .cn-wrapper li a span {
font-size: 1.1em;
opacity: 0.7;
}
/* for a central angle x, the list items must be skewed by 90-x degrees
in our case x=40deg so skew angle is 50deg
items should be rotated by x, minus (sum of angles - 180)2s (for this demo) */
.csstransforms .cn-wrapper li{
-webkit-transform: rotate(calc(-10deg + var(--n) * 360deg / 9)) skew(50deg);
-ms-transform: rotate(calc(-10deg + var(--n) * 360deg / 9)) skew(50deg);
-moz-transform: rotate(calc(-10deg + var(--n) * 360deg / 9)) skew(50deg);
transform: rotate(calc(-10deg + var(--n) * 360deg / 9)) skew(50deg);
}
/*.csstransforms .cn-wrapper li:nth-child(odd) a {
background-color: #a11313;
background-color: hsla(0, 88%, 63%, 1);
}
.csstransforms .cn-wrapper li:nth-child(even) a {
background-color: #a61414;
background-color: hsla(0, 88%, 65%, 1);
}
.csstransforms .cn-wrapper li:last-child a {
background-color: #a61414;
background-color: hsl(343, 82%, 50%);
}*/
/* active style */
.csstransforms .cn-wrapper li.active a {
background-color: #b31515;
background-color: hsla(0, 88%, 70%, 1);
}
/* hover style */
.csstransforms .cn-wrapper li:not(.active) a:hover,
.csstransforms .cn-wrapper li:not(.active) a:active,
.csstransforms .cn-wrapper li:not(.active) a:focus {
background-color: #b31515;
background-color: hsla(0, 88%, 70%, 1);
}
.csstransforms .cn-wrapper li:not(.active) a:focus {
position: fixed;
}
/* fallback */
.no-csstransforms .cn-button {
display: none;
}
.no-csstransforms .cn-wrapper li {
position: static;
float: left;
font-size: 1em;
height: 5em;
width: 5em;
background-color: #eee;
text-align: center;
line-height: 5em;
}
.no-csstransforms .cn-wrapper li a {
display: block;
width: 100%;
height: 100%;
text-decoration: none;
color: inherit;
font-size: 1.3em;
border-right: 1px solid #ddd;
}
.no-csstransforms .cn-wrapper li a:last-child {
border: none;
}
.no-csstransforms .cn-wrapper li a:hover,
.no-csstransforms .cn-wrapper li a:active,
.no-csstransforms .cn-wrapper li a:focus {
background-color: white;
}
.no-csstransforms .cn-wrapper li.active a {
background-color: #6F325C;
color: #fff;
}
.no-csstransforms .cn-wrapper {
font-size: 1em;
height: 5em;
width: 25.15em;
bottom: 0;
margin-left: -12.5em;
overflow: hidden;
position: fixed;
z-index: 10;
left: 50%;
border: 1px solid #ddd;
}
#media screen and (max-width:480px) {
.csstransforms .cn-wrapper {
font-size: .68em;
}
.cn-button {
font-size: 1em;
}
.csstransforms .cn-wrapper li {
font-size: 1.52em;
}
}
#media screen and (max-width:320px) {
.no-csstransforms .cn-wrapper {
width: 15.15px;
margin-left: -7.5em;
}
.no-csstransforms .cn-wrapper li {
height: 3em;
width: 3em;
}
}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.js"></script>
<script src="https://use.fontawesome.com/2972279885.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<div class="cn-wrapper opened-nav" id="cn-wrapper">
<ul>
<li style="--n: 0"><i class="fa fa-film"></i></li>
<li style="--n: 1"><i class="fa fa-headphones"></i></li>
<li style="--n: 2"><i class="fa fa-bookmark"></i></li>
<li style="--n: 3"><i class="fa fa-cog"></i></li>
<li style="--n: 4"><i class="fa fa-flag"></i></li>
<li style="--n: 5"><i class="fa fa-calculator"></i></li>
<li style="--n: 6"><i class="fa fa-coffee"></i></li>
<li style="--n: 7"></li>
<li style="--n: 8"></li>
</ul>
</div>
If I remove scale in transform from line 18 and 48 (leave translateY only), the code works, but not decent. I want to add scale transition to make the transition smoother, but leads to the rectangle and the tooltip not going well along together. How to fix this?
.tooltip {
display: block;
background: #F24B5B;
color: white;
margin: 5em auto;
padding: 1em 0;
text-align: center;
width: 13em;
position: relative;
--rec-size: .3em;
--half-rec-size: calc( var(--rec-size) / 2 )
}
.tooltip::before,
.tooltip::after {
position: absolute;
opacity: 0;
transform: scale(.5) translateY(1em);
transform-origin: center bottom;
transition:
opacity .3s ease-out,
transform .15s ease-out
;
}
.tooltip::after {
content: '';
border: var(--rec-size) solid #0000;
}
.tooltip::before {
content: attr(title);
width: 80%;
line-height: 2em;
border-radius: .2em;
background: #000b;
}
.tooltip.top::before {
bottom: calc( 100% + var(--rec-size) );
left: 10%;
}
.tooltip.top::after {
border-top: var(--rec-size) solid #000b;
bottom: calc( 100% - var(--rec-size) );
left: calc( 50% - var(--half-rec-size) );
}
.tooltip:hover::before,
.tooltip:hover::after {
opacity: 1;
transform: scale(1) translateY(0);
}
<div class="tooltip top" title="Tooltip on top!">
Hover over me
</div>
.tooltip {
display: block;
background: #F24B5B;
color: white;
margin: 5em auto;
padding: 1em 0;
text-align: center;
width: 13em;
position: relative;
--rec-size: .3em;
--half-rec-size: calc( var(--rec-size) / 2 )
}
.tooltip::before,
.tooltip::after {
position: absolute;
opacity: 0;
transform: scale(.5) translateY(1em);
transform-origin: center bottom;
transition:
opacity .3s ease-out,
transform .15s ease-out
;
}
.tooltip::after {
transform: translateY(0.5em);
}
.tooltip::after {
content: '';
border: var(--rec-size) solid #0000;
}
.tooltip::before {
content: attr(title);
width: 80%;
line-height: 2em;
border-radius: .2em;
background: #000b;
}
.tooltip.top::before {
bottom: calc( 100% + var(--rec-size) );
left: 10%;
}
.tooltip.top::after {
border-top: var(--rec-size) solid #000b;
bottom: calc( 100% - var(--rec-size) );
left: calc( 50% - var(--half-rec-size) );
}
.tooltip:hover::before,
.tooltip:hover::after {
opacity: 1;
transform: scale(1) translateY(0);
}
<div class="tooltip top" title="Tooltip on top!">
Hover over me
</div>
::after and ::before set a different translateY
.tooltip::after {
transform: translateY(0.5em);
}
Or like the one above
.tooltip::after,.tooltip::before {
transform-origin: center 140%;
}
I'm a beginner to CSS and having a crazy time trying to figure how to create the following:
The circle represents 100% and the filled in green would represent the 62%. Is this even possible in just CSS or would need some javascript to create?
here's example with progressbar.js
// progressbar.js#1.0.0 version is used
// Docs: http://progressbarjs.readthedocs.org/en/1.0.0/
var bar = new ProgressBar.Circle(container, {
color: '#7ed321',
// This has to be the same size as the maximum width to
// prevent clipping
strokeWidth: 5,
trailWidth: 5,
trailColor: '#73787d',
easing: 'easeInOut',
duration: 1400,
text: {
autoStyleContainer: false
},
from: { color: '#7ed321', width: 5 },
to: { color: '#7ed321', width: 5 },
// Set default step function for all animate calls
step: function(state, circle) {
circle.path.setAttribute('stroke', state.color);
circle.path.setAttribute('stroke-width', state.width);
var value = Math.round(circle.value() * 100);
if (value === 0) {
circle.setText('');
} else {
circle.setText(value+'%');
}
}
});
bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
bar.text.style.fontSize = '3rem';
bar.animate(62*0.01); // Number from 0.0 to 1.0 //currently set to 62%
#container {
width: 200px;
height: 200px;
position: relative;
background: #454b52;
padding: 20px;
}
<link href="https://fonts.googleapis.com/css?family=Raleway:400,300,600,800,900" rel="stylesheet" type="text/css">
<script src="https://rawgit.com/kimmobrunfeldt/progressbar.js/1.0.0/dist/progressbar.js"></script>
<div id="container"></div>
Created a demo with pure css-
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
.page {
margin: 40px;
}
h1 {
margin: 40px 0 60px 0;
}
.dark-area {
background-color: #666;
padding: 40px;
margin: 0 -40px 20px -40px;
clear: both;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
.rect-auto {
clip: rect(auto, auto, auto, auto);
}
.pie,
.c100 .bar {
position: absolute;
border: 0.08em solid #307bbb;
width: 0.84em;
height: 0.84em;
clip: rect(0em, 0.5em, 1em, 0em);
border-radius: 50%;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.pie-fill {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
.c100 {
position: relative;
font-size: 120px;
width: 1em;
height: 1em;
border-radius: 50%;
float: left;
margin: 0 0.1em 0.1em 0;
background-color: #cccccc;
}
.c100 *,
.c100 *:before,
.c100 *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.c100.center {
float: none;
margin: 0 auto;
}
.c100.big {
font-size: 240px;
}
.c100.small {
font-size: 80px;
}
.c100 > span {
position: absolute;
width: 100%;
z-index: 1;
left: 0;
top: 0;
width: 5em;
line-height: 5em;
font-size: 0.2em;
color: #cccccc;
display: block;
text-align: center;
white-space: nowrap;
-webkit-transition-property: all;
-moz-transition-property: all;
-o-transition-property: all;
transition-property: all;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-out;
-moz-transition-timing-function: ease-out;
-o-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.c100:after {
position: absolute;
top: 0.08em;
left: 0.08em;
display: block;
content: " ";
border-radius: 50%;
background-color: #f5f5f5;
width: 0.84em;
height: 0.84em;
-webkit-transition-property: all;
-moz-transition-property: all;
-o-transition-property: all;
transition-property: all;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-in;
-moz-transition-timing-function: ease-in;
-o-transition-timing-function: ease-in;
transition-timing-function: ease-in;
}
.c100 .slice {
position: absolute;
width: 1em;
height: 1em;
clip: rect(0em, 1em, 1em, 0.5em);
}
.c100.p50 .bar {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
.c100:hover {
cursor: default;
}
.c100:hover > span {
width: 3.33em;
line-height: 3.33em;
font-size: 0.3em;
color: #307bbb;
}
.c100:hover:after {
top: 0.04em;
left: 0.04em;
width: 0.92em;
height: 0.92em;
}
.c100.dark {
background-color: #777777;
}
.c100.dark .bar,
.c100.dark .fill {
border-color: #c6ff00 !important;
}
.c100.dark > span {
color: #777777;
}
.c100.dark:after {
background-color: #666666;
}
.c100.dark:hover > span {
color: #c6ff00;
}
.c100.green .bar,
.c100.green .fill {
border-color: #4db53c !important;
}
.c100.green:hover > span {
color: #4db53c;
}
.c100.green.dark .bar,
.c100.green.dark .fill {
border-color: #5fd400 !important;
}
.c100.green.dark:hover > span {
color: #5fd400;
}
.c100.orange .bar,
.c100.orange .fill {
border-color: #dd9d22 !important;
}
.c100.orange:hover > span {
color: #dd9d22;
}
.c100.orange.dark .bar,
.c100.orange.dark .fill {
border-color: #e08833 !important;
}
.c100.orange.dark:hover > span {
color: #e08833;
}
<div class="page">
<div class="dark-area clearfix">
<!-- default -->
<div class="clearfix">
<div class="c100 p50 big dark">
<span>50%</span>
<div class="slice">
<div class="bar"></div>
<div class="fill"></div>
</div>
</div>
</div>
<!-- /default -->
</div>
<!-- /.dark-area -->
</div>
I would like both to behave like webkit, but for some reason in webkit works as I expected but -moz- does the animation when mouseout the .porftolio item,
Any idea why?
CSS:
.portfolio-item {
float: left;
width: 300px;
height: 300px;
margin: 0.5%;
position: relative;
text-align: center;
background: orange;
overflow: hidden;
-webkit-transition: 0.4s all ease;
-moz-transition: 0.4s all ease;
transition: 0.4s all ease;
}
.portfolio-item a:hover:after {
content: " ";
position: absolute;
left: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(255, 255, 255, 0.4), transparent 100%);
}
.portfolio-item h4, .portfolio-item img {
-webkit-transition: 0.4s all ease;
-moz-transition: 0.4s all ease;
transition: 0.4s all ease;
}
.portfolio-item img {
width: 100%;
hegight: 100%;
position: absolute;
top: 0;
left: 0;
}
.portfolio-item:before {
content: '';
display: -moz-inline-stack;
display: inline-block;
vertical-align: middle;
*vertical-align: auto;
zoom: 1;
*display: inline;
height: 100%;
vertical-align: middle;
}
.portfolio-item h4 {
opacity: 0;
color: white;
font-size: 30px;
vertical-align: middle;
/*#include transform(scale(.5));*/
display: -moz-inline-stack;
display: inline-block;
vertical-align: middle;
*vertical-align: auto;
zoom: 1;
*display: inline;
/* sino en safari no va */
width: 200px;
font-weight: bold;
text-transform: uppercase;
-webkit-transform: translateX(-2px);
-moz-transform: translateX(-2px);
-ms-transform: translateX(-2px);
transform: translateX(-2px);
}
.portfolio-item:hover {
z-index: 9;
}
.portfolio-item:hover img {
opacity: 0;
-webkit-transform: scale(1.07);
-moz-transform: scale(1.07);
-ms-transform: scale(1.07);
transform: scale(1.07);
}
.portfolio-item:hover h4 {
-webkit-transform: translateX(3px);
-moz-transform: translateX(3px);
-ms-transform: translateX(3px);
transform: translateX(3px);
/*-webkit-animation-duration: 0.4s;
-webkit-transform-origin:50% 50%;
-webkit-animation-timing-function: linear;
-moz-animation-duration: 0.4s;
-moz-transform-origin:50% 50%;
-moz-animation-timing-function: linear;
-webkit-animation-name: shake;
-moz-animation-name: shake;
-o-animation-name: shake;
animation-name: shake;*/
opacity: 1;
}
HTML:
<ul><li class="portfolio-item" style="background-color: #6220E5;">
<a href="#">
<img src="http://dummyimage.com/300x300/dddddd/cccccc" alt="camper" />
<h4>Text goes here</h4>
</a>
</li></ul>
Test:
http://jsfiddle.net/kuX39/
-EDIT-
Funny thing is that I noticed that if instead of applying it to :hover i apply it to .hover and toggle the class then the animations works the same... :S
The problem comes from this rule:
.portfolio-item a:hover:after {
content: " ";
position: absolute;
left: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(255, 255, 255, 0.4), transparent 100%);
}
where you define all the after pseudoelement only in the hover state. If the a element is not hovered, the pseudo element is undefined, and can take whatever value the browser decides.
If you set the same on the un-hovered element, it works fine.
.portfolio-item a:after {
content: " ";
position: absolute;
left: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(255, 255, 255, 0.4), transparent 100%);
}
updated demo
By the way, my firefox version is using transition and not moz-transition