Animations wont run - css

I'm trying to run some animations in scss and I'm running into difficulty. In chrome dev tools it shows my element has the correct animation set and I've even copy pasted the keyframes rule into codepen and tried it there and it worked, yet when I run it in my website it doesn't work. I've been stuck with this for hours.
Here is a fiddle demonstraiting: http://jsfiddle.net/58xrZ/1/
This was written in Scss and HAML and is as follows
ul.tab-selection {
width: 38.338926174%;
float: right;
position: relative;
min-height: 20em;
li {
text-align: center;
height: 6em;
width: 6em;
border-radius: 50%;
position: absolute;
&:first-child {
background : radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
background : -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
background : -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
top: 0;
right: 50%;
margin-right: -50px;
animation-name: first;
animation-duration: 3s;
-webkit-animation-name: first;
-webkit-animation-duration: 3s;
a {
width: 4em;
padding: 2em 1em
}
}
&:not(:first-child){
bottom: 1.5em;
}
&:nth-child(2) {
background: radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
background: -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
background: -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
filter: progid:DXImageTransform.Microsoft.Alpha(Stlye=2);
}
&:last-child {
background : radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
background : -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
background : -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
filter: progid:DXImageTransform.Microsoft.Alpha(Stlye=2);
right: 0;
a {
left: 3px;
padding: 2em 1em;
}
}
a {
position: absolute;
right: 0;
left: 0;
top: 0;
font-family: 'Lora', serif;
color: #AE843D;
text-shadow: 0 -1px 0 black;
padding: 1.5em 1em;
&:hover {
color: #3D6F51;
}
}
}
}
and in Haml
%ul.tab-selection
%li.active.current-projects
%a{ :href => '#current-projects', 'data-toggle' => 'tab' }
Current
%br Projects
%li.secret
%a{ :href => '#secret', 'data-toggle' => 'tab' }
The
%br
Secret Shop
%li.favorite
%a{ :href => '#favorite', 'data-toggle' => 'tab' }
Favorite
%br Links

You need to place the keyframes at the bottom of your CSS. You also need to have browser prefixed versions of the #keyframes animation(s) so that when you say -webkit-animation:... for example it will actually go to the #-webkit-keyframes
Demo
It likely only worked in CodePen because it was using a prefixer, which automatically adds prefixes

Related

Unexpected nonstandard direction

I am working on a projekt where I need to check Sonar analyzis due to clean code and quality.
I face the following issue and have unfortunately no clue what is the problem.
I have the following CSS file:
/* progress bar IE */
progress {
color: #507311;
background: transparent;
border-radius: 2px;
border: solid 1px;
padding: 0px;
width: 160px;
height: 14px;
}
/* progress bar FF */
progress::-moz-progress-bar {
background-image: -moz-linear-gradient(center bottom, rgba(75, 108, 16, 1) 37%, rgba(134, 181, 29, 1) 69%);
}
/* progress bar Chrome */
progress::-webkit-progress-bar {
background: transparent;
}
progress::-webkit-progress-value {
background-image: -webkit-linear-gradient(bottom, rgba(75, 108, 16, 1) 37%, rgba(134, 181, 29, 1) 69%);
border-radius: 2px;
}
At -moz-progress-bar I got the following Sonar issue:
Unexpected nonstandard direction
I have tried the followings:
progress::-moz-progress-bar {
background-image: -moz-linear-gradient(to bottom, rgba(75, 108, 16, 1) 37%, rgba(134, 181, 29, 1) 69%);
}
and
progress::-moz-progress-bar {
background-image: -moz-linear-gradient(center bottom, rgba(75, 108, 16, 1) 37%, rgba(134, 181, 29, 1) 69%);
background-image: linear-gradient(to bottom, rgba(75, 108, 16, 1) 37%, rgba(134, 181, 29, 1) 69%);
}
They did not help.
Has anybody a clue what is wrong?
https://rules.sonarsource.com/css/RSPEC-4651

How to set header with two different colors for the left and right side

Header left and right side should display white and blue colors while body background-color grey.
White color for left side area with logo inside header and blue color for right one.
Using colorzilla, I've made background for the container1 horizontally half blue for the right side. Then I included a couple pseudo elements for razor-blade effect. And when I set background-color for body I realized that the area with my logo inside header colored with body color.
I read about linear-gradient but I was told that using it I'll face cross-browsing issues because even if you do it the way it should still there are a list of versions or even browsers that wouldn't understand it.
That's exactly where I find myself stuck. I need that all browsers and versions understood this code or as much as possible in this case. Please tell me how can I do that without using Colorzilla and linear-gradient.
#media only screen and (min-width: 900px) {
.container1 {
width: 100%;
margin: 0 auto;
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#1e5799+44,1e5799+44,7db9e8+45,1e5799+45,7db9e8+46,7db9e8+46,7db9e8+46,7db9e8+46,7db9e8+46,7db9e8+46,1e5799+46,7db9e8+50,1e5799+50,1e5799+100&0+44,0+46,1+47 */
background: -moz-linear-gradient(left, rgba(30, 87, 153, 0) 44%, rgba(30, 87, 153, 0) 45%, rgba(30, 87, 153, 0) 46%, rgba(30, 87, 153, 1) 47%, rgba(30, 87, 153, 1) 50%, rgba(30, 87, 153, 1) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(left, rgba(30, 87, 153, 0) 44%, rgba(30, 87, 153, 0) 45%, rgba(30, 87, 153, 0) 46%, rgba(30, 87, 153, 1) 47%, rgba(30, 87, 153, 1) 50%, rgba(30, 87, 153, 1) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, rgba(30, 87, 153, 0) 44%, rgba(30, 87, 153, 0) 45%, rgba(30, 87, 153, 0) 46%, rgba(30, 87, 153, 1) 47%, rgba(30, 87, 153, 1) 50%, rgba(30, 87, 153, 1) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#001e5799', endColorstr='#1e5799', GradientType=1);
/* IE6-9 */
}
.logo {
width: 250px;
}
header {
display: flex;
justify-content: space-between;
padding: 0em 3.15em;
}
.cont {
position: relative;
}
.cont::before {
position: absolute;
content: '';
width: 40em;
height: 15rem;
background: blue;
bottom: -.8em;
z-index: -1;
}
.cont::before {
left: 42%;
transform: skew(-30deg);
}
.cont::after {
position: absolute;
content: '';
width: 1.6em;
height: 10rem;
background: green;
bottom: -.8em;
}
.cont::after {
left: 38.9%;
transform: skew(-30deg);
}
<div class="container1">
<div class="cont">
<header>
<img src="/images/logo.png" alt="O-Credit logo" class="logo">
<nav>
<div id="menu-bar" class="hide-desk">
<div class="menu" id="menu">
<div id="bar1" class="bar"></div>
<div id="bar2" class="bar"></div>
<div id="bar3" class="bar"></div>
</div>
</div>
<ul class="show-desk hide-mob" id="nav">
<li id="exit" class="exit-btn close hide-desk">
</li>
<li>Обрати позику</li>
<li>Компанії</li>
<li>Види позик</li>
<li>Блог</li>
<li></li>
</ul>
</nav>
</header>
</div>
</div>
Left side of header with logo to show background white. Right side of the same header to show background blue. And set Body to show background grey everywhere but header.
.header {
display: flex;
justify-content: space-between;
padding: 0em 3.15em;
background: linear-gradient(to right, blue 50%, red 50%)
}

Gradient overlay on Image with single line of CSS

I'm trying to put a gradient on a background image using this code
background: url('../img/newspaper.jpeg'),linear-gradient(to bottom right,#002f4b, #dc4225);
background-size: cover;
I'm getting the image but the gradient is not being applied
Add the gradient first and then add the image url, just like this:
background: linear-gradient(rgba(244, 67, 54, 0.95),
rgba(33, 150, 243, 0.75),
rgba(139, 195, 74, 0.75),
rgba(255, 87, 34, 0.95)),
url("http://placehold.it/200x200");
Or look at the snippet below:
.bg {
background: linear-gradient(
rgba(244, 67, 54, 0.45),
rgba(33, 150, 243, 0.25),
rgba(139, 195, 74, 0.25),
rgba(255, 87, 34, 0.45)),
url("http://placehold.it/200x200");
width: 200px;
height: 200px;
}
<div class="bg"></div>
Hope this helps!
div {
width: 350px;
height: 350px;
background: linear-gradient(to bottom right, rgba(0,47,75,.9), rgba(220,66,37,.9)), url(http://placehold.it/350x350);
background-size: cover;
}
<div></div>
do it in one line like below, I gave an example for that, see it
background-image: linear-gradient(to start-direction end-direction, color1, color2, url("imageUrl");
#hero {
height: 320px;
width: 100%;
background-image: linear-gradient(to right bottom, rgba(99, 102, 241, .9), rgba(219, 99, 139, .9)), url("https://i.picsum.photos/id/305/600/300.webp?hmac=QcFzy6dHM3Qs5MQwTjvnHEkSoTGAfg_VRgbH5g7pUQM");
background-size: cover;
}
<div id="hero"></div>

Converting gradient image to css properties [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I need to convert this image into a css. I tried to use online tools with no success.
Any suggestions?
Image:
Try this:
div {
width: 600px;
height: 170px;
background: -webkit-radial-gradient(circle, #00517D, #004367);
background: -moz-radial-gradient(circle, #00517D, #004367);
background: -o-radial-gradient(circle, #00517D, #004367);
background: radial-gradient(circle, #00517D, #004367);
}
<div></div>
http://gradientfinder.com/ - Image gradient to css converter online
Your css for particular image
background: -webkit-linear-gradient(339deg, rgb(5, 68, 99) 0%, rgb(5, 68, 99) 97%);
background: -o-linear-gradient(339deg, rgb(5, 68, 99) 0%, rgb(5, 68, 99) 97%);
background: -ms-linear-gradient(339deg, rgb(5, 68, 99) 0%, rgb(5, 68, 99) 97%);
background: -moz-linear-gradient(339deg, rgb(5, 68, 99) 0%, rgb(5, 68, 99) 97%);
background: linear-gradient(111deg, rgb(5, 68, 99) 0%, rgb(5, 68, 99) 97%);
I guess you want this image for background... maybe? You can try css gradient.
#gradient {
background: -webkit-radial-gradient((rgb(25, 85, 124), rgb(19, 68, 99)); /* Safari 5.1 to 6.0 */
background: -o-radial-gradient((rgb(25, 85, 124), rgb(19, 68, 99)); /* For Opera 11.6 to 12.0 */
background: -moz-radial-gradient((rgb(25, 85, 124), rgb(19, 68, 99)); /* For Firefox 3.6 to 15 */
background: radial-gradient((rgb(25, 85, 124), rgb(19, 68, 99)); /* Standard syntax (must be last) */
}
Color values are adjusted to fit your image

CSS Gradient Animate

I'm trying to animate a CSS gradient as described here but I can't get it to work. As an example I've put together this jsfiddle.
As a overview, it seems that CSS transitions on gradients doesn't seem to work.
div#Machine {
-webkit-transition: background 5s;
-moz-transition: background 5s;
-ms-transition: background 5s;
-o-transition: background 5s;
transition: background 5s;
background: rgb(71, 234, 46);
background: -moz-linear-gradient(top, rgba(71, 234, 46, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(71, 234, 46, 1)), color-stop(100%, rgba(63, 63, 63, 1)));
background: -webkit-linear-gradient(top, rgba(71, 234, 46, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -o-linear-gradient(top, rgba(71, 234, 46, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -ms-linear-gradient(top, rgba(71, 234, 46, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: linear-gradient(top, rgba(71, 234, 46, 1) 0%, rgba(63, 63, 63, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#47ea2e', endColorstr='#3f3f3f', GradientType=0);
}
div#Machine.doublewin {
background: rgb(247, 247, 49);
background: -moz-linear-gradient(top, rgba(247, 247, 49, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(247, 247, 49, 1)), color-stop(100%, rgba(63, 63, 63, 1)));
background: -webkit-linear-gradient(top, rgba(247, 247, 49, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -o-linear-gradient(top, rgba(247, 247, 49, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: -ms-linear-gradient(top, rgba(247, 247, 49, 1) 0%, rgba(63, 63, 63, 1) 100%);
background: linear-gradient(top, rgba(247, 247, 49, 1) 0%, rgba(63, 63, 63, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f7f731', endColorstr='#3f3f3f', GradientType=0);
}
I'm using some javascript / jQuery to add / remove the "doublewin" class. When using the same code but using a solid background it works fine, as shown in the jsfiddle link.
Is it actually possible to animate a CSS3 gradient or am I doing something wrong?
Any help is greatly appreciated.
It seems you can't animate css background gradients, but you can still animate opacity to try and get this to work.
If you have two containers, one on top of the other with the exact same width and height, each with a different gradient background colour, you can fade out the container on top to opacity: 0.
If you don't want to add extra mark-up to your code for the second background container, you can use the CSS pseudo selectors ::before and ::after to do this.

Resources