I have referred to this guide in order to attempt to get a series of images that display on the screen one after another on my website. On the guide i'm using Demo 3 and I've matched all the code from Demo 3 of the guide to suit my chosen images on my page. However for some reason the image on my page doesn't seem to be fading to the other image after a short time. I was wondering if anyone could point me in the right direction so my code is working like the one on demo 3 of the guide
Here is the HTML content for the page including the two images used:
<!--INDEX CONTENT-->
<div id="index_banner">
<img class="bottom" src="images/SPAWN IMAGE.png" alt="INDEX BANNER">
<img class="top" src="images/SURVIVAL IMAGE - GAMEMODES.png" alt="INDEX BANNER 2">
</div>
<div id="welcome_text">
<h3>Welcome to CRAFT412</h3>
<h3>We are currently running version 1.8.1</h3>
<h3>Survival / PurePVP / GamesWorld</h3>
</div>
<div id="trailer_title">
<h4><br>SERVER TRAILER</h4>
</div>
<div id="trailer_video">
<iframe width="832" height="468" src="http://www.youtube.com/embed/dfbWw757Iow"></iframe>
</div>
</div>
And here is the CSS:
/*INDEX PAGE CSS*/
#index_banner {height:360px;
position:relative;
margin:0 auto;}
#index_banner img {position:absolute;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;}
#keyframes cf3FadeInOut {
0% {
opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}
#index_banner img.top {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 10s;
animation-direction: alternate;
}
#welcome_text {padding-top: 20px;
text-align: center;
line-height: 2em;}
#trailer_title {text-align: center;}
#trailer_video {padding-top: 10px;
text-align: center;
padding-bottom:20px;}
the #keyframe rule works inside the animation property;
and you're not defining the animation property anywhere,
so to begin addanimation: cf4FadeInOut 8s; to #index_banner img selector.
Related
This question already has answers here:
Transitions on the CSS display property
(37 answers)
CSS Auto hide elements after 5 seconds
(5 answers)
Closed 1 year ago.
How can I make a div disappear in 5s when hovering by only using css? I tried something like this:
.a {
display: block;
transition: display 5s;
}
.a:hover {
display: none;
}
Display property doesn't get affected by transitions. You can use opacity instead.
a{
opacity:1;
transition: opacity 5s linear;
}
a:hover{
opacity:0;
transition: opacity 5s linear;
}
Here is a working demo.
a{
opacity:1;
transition: opacity 5s linear;
}
a:hover{
opacity:0;
transition: opacity 5s linear;
}
<a> I will disapear </a>
yes but its can not be done right away like you have been doing. It requires a little more effort.
<a class="hide" href="#">Make me disappear in 5s </a>
CSS:
a.hide:hover {
animation: animateVisibility 0s ease-in 5s forwards;
animation-fill-mode: forwards;
}
#keyframes animateVisibility {
to {
width:0;
height:0;
visibility:hidden;
}
}
I built a preloading screen for a website with a loading bar that is animated with CSS #keyframes. Works fine on Chrome and Firefox, but on macOS Safari it gets very discrete. Here is a video demo of how it looks on Safari: https://www.youtube.com/watch?v=ODV5lN2xZSI&feature=youtu.be
As you can see, loading bar background (gray line) and the bar itself (black line) twitch instead of going smoothly from 0% width to 100%. What could be a problem, is this known bug of Safari? Latest macOS and Safari.
#keyframes loading-wrapper-anim {
0% {
width:0%;
}
100% {
width:100%;
}
}
.preloader .loading_wrapper {
position:absolute;
width:0%;
height:1px;
background:#dbdbdb;
top:12rem;
animation: loading-wrapper-anim 1s;
animation-delay: 1s;
animation-fill-mode: forwards;
align-self:flex-start; /*this one is because of the parent element*/
}
.preloader .loading_wrapper .loading_bar {
height:100%;
width:0%;
height:100%;
background:#000;
animation: loading-wrapper-anim 3s;
animation-delay: 2s;
animation-fill-mode: forwards;
}
<div class="preloader">
<div class="loading_wrapper">
<div class="loading_bar">
</div>
</div>
</div>
Smooth animation is expected.
Thank you.
You can attempt to force the hardware acceleration by adding a translateZ on the animation.
.preloader .loading_wrapper {
position:absolute;
width:0%;
height:1px;
background:#dbdbdb;
top:12rem;
animation: loading-wrapper-anim 1s;
animation-delay: 1s;
animation-fill-mode: forwards;
align-self:flex-start;
/* Add this */
-webkit-transform: translateZ(0);
}
JSFiddle
Alternatively, you can look into using the will-change method as a last resort for smoother animations.
https://developer.mozilla.org/en-US/docs/Web/CSS/will-change
The way I fixed it is instead of trying to manipulate width of an element (which causes redrawing each time the width changes), did the following:
#keyframes loading-wrapper-anim {
0% {
transform:scaleX(0);
}
100% {
transform:scaleX(1);
}
}
.preloader .loading_wrapper {
position:absolute;
width:100%;
height:1px;
background:#dbdbdb;
top:12rem;
animation: loading-wrapper-anim 1s;
animation-delay: 1s;
animation-fill-mode: forwards;
align-self:flex-start; /*this one is because of the parent element*/
transform:scaleX(0);
transform-origin:0% 0%;
}
.preloader .loading_wrapper .loading_bar {
height:100%;
width:100%;
height:100%;
background:#000;
animation: loading-wrapper-anim 3s;
animation-delay: 2s;
animation-fill-mode: forwards;
transform:scaleX(0);
transform-origin:0% 0%;
}
I used transform:scaleX() in conjunction with transform-origin:0% 0% (this one sets center of transformation to the top left corner) to emulate width change without actually changing it.
Conclusion: use transform where/when possible. They are more efficient in terms of CSS animations and transitions.
I have used a CSS3 effect where the black box scales to 0.25 to the top-left corner on a mouse hover.
The problem I face here is that once hovered, the animation starts and if the mouse pointer is still within range of the black box (and get hovered), the animation again restarts from the existing point. This prevents a smooth transition. How can this be solved?
This link contains the black box
Below is the code. Note that the black box is wrapped in the CSS clas 'image-effect'.
.image-effect {
animation-name: slideUp;
transition: all 0.5s;
-webkit-animation-name: slideUp;
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-timing-function: ease;
-webkit-animation-timing-function: ease;
}
.image-effect:hover {
transform: scale(0.25) ;
transform-origin: top left;
overflow: hidden;
}
Thanks in advance.
You need to add a parent element that contains the hover, but does not transform. Your CSS would end up looking something like this:
.parent-element:hover .image-effect {
transform: scale(0.25) ;
transform-origin: top left;
overflow: hidden;
}
Check out this fiddle http://jsfiddle.net/7wdqmhrd/
Target an inner div element with the effect instead like the following :
.image-effect div {
animation-name: slideUp;
transition: all 0.5s;
-webkit-animation-name: slideUp;
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-timing-function: ease;
-webkit-animation-timing-function: ease;
}
.image-effect:hover div {
transform: scale(0.25);
transform-origin: top left;
overflow: hidden;
}
Hope it helps!
1) Add an inner div tag
<div class="image-effect">
<div> // Beginning Tag Added
<img class="size-full wp-image-225 alignleft" src="http://albion123.byethost7.com/creative/wp-content/uploads/2015/01/bg11.png" alt="bg1" data-id="225">
</div> // Ending Tag Added
</div>
2) Just add a div tag to both your classes
.image-effect div
.image-effect:hover div
Because you are wanting to move the inner div.
I'm trying to make hover images and add a link to the div but the div does not fit to page.
For example:
http://test.peterstavrou.com/
See how the image gets cut off?
Anyone have any ideas?
Below is my code.
CSS
#cf {
position:relative;
margin:0 auto;
}
#cf img {
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
HTML:
<div id="cf"><img class="bottom" src="http://www.peterstavrou.com/wp-content/uploads/2014/11/eBay-Listing-Template-Price.jpg" alt="eBay Template Listing" width="292" height="311" /><img class="top" src="http://www.peterstavrou.com/wp-content/uploads/2014/11/eBay-Listing-Template.jpg" alt="eBay Template Listing" width="292" height="311" /></div>
<strong>Summary:</strong> TEST TEST TEST
<a title="eBay Template Listing" href="http://www.peterstavrou.com/product/ebay-listening-template/">Click here for more information.</a>
jsFiddle http://jsfiddle.net/hz80govj/
the div only contains an image, so it's width/height is derived from that image width/height, which is currently set to width="292" height="311".
If you want the div/image to adjust to screen size, remove the width/height from the image and set image size using css:
img{
max-width: 100%;
}
Your question is not at all clear, But as I understood you need to fit the div to the size of the picture. If I am correct use the following CSS.
#cf {
position:relative;
float:left;
margin:0 auto;
}
.top {
position:absolute;
left:0;
-webkit-transition:opacity 1s ease-in-out;
-moz-transition:opacity 1s ease-in-out;
-o-transition:opacity 1s ease-in-out;
transition:opacity 1s ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
.bottom {
position:inherit;
}
This is my first try with css3 animation. I'm trying to create a letter spacing animation in which the letters are closely spaced at first and then letter spacing increases. So far I've found a code which allows the spacing to happen on hover. How can I remove the hover and make the animation when the page opens.
Heres the fiddle http://jsfiddle.net/Lventbau/
and the code
p {
letter-spacing:-2px;
-webkit-transition: letter-spacing, 1s;
-moz-transition: letter-spacing, 1s;
-o-transition: letter-spacing, 1s;
transition: letter-spacing, 1s;
}
p:hover {letter-spacing:2px;}
You can accomplish it with css3 animations jsfiddle :
p {
letter-spacing:2px;
-webkit-animation: myanim 1s;
animation: myanim 1s;
}
#-webkit-keyframes myanim {
0% { letter-spacing: -2px; }
100% { letter-spacing:2px; }
}
#keyframes myanim {
0% { letter-spacing: -2px; }
100% { letter-spacing:2px; }
}
You can find animation documentation here