Automatic Multiple Image switch with different links on each IMG - html

Background:
Finding improved ways to use CSS, I came across the proposition of using image transitions for good effects.
After a few stumbles, I managed to do this with the help of some references to make a smooth transition in hover.
Now I want it automatic and with links in each picture, but I'm at a loss at the code.
Current JSFiddle:
None, JSFIDDLE doesn't accept IMG and I can't show there.
<div class="container">
<img src="sky.jpg">
<img class="front" src="bear.jpg">
</div>
.container
{
position:relative;
height:500px;
width:500px;
margin:0 auto;
}
.container img
{
position:absolute;
transition: opacity 1s ease-in-out;
}
.container img.front:hover
{
opacity:0;
}
Problem:
This HTML-CSS works but for a single image switch (2 images) on hover, not for multiple ones automatically.
Need:
A change in the code which allows multiple switches using CSS and HTML only, with different links on each image.
I know there are possibilities with JQUERY and JAVACRIPT, I wish for a solution without these two.
Solution Code restrictions and parameters:
No JQUERY nor JAVASCRIPT
Multiple browser compatibility (doesn't need to be very old ones)
Possibility of multiple links in each image switch
Many Thanks for all help provided.

Try this you have to move your cursor a slight (shake it a bit) to see the change in the link notice the change in the link http://jsfiddle.net/fc3nb5rL/1/
i used z-index instead of opacity
.back {
z-index:1;
}
#-webkit-keyframes anim {
from {
z-index:1;
}
to {
z-index:-2;
}
}
.back:hover {
-webkit-animation:anim 5s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function: ease-in-out;
}
#-webkit-keyframes anim2 {
from {
z-index:1;
}
to {
z-index:-2;
}
}
.front:hover{
-webkit-animation:anim2 5s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function: ease-in-out;
}

Related

CSS opacity transition on page open

I want my CSS div to be completely invisible when page opens but after 2s appear on screen.
I tried setting opacity: 0; and then transition: opacity 100 2s; but it didn't work. I don't want CTA for example for it to happen after they hover or something but instead I want it to happen even if the user doesn't move the mouse. Please help!
You can use CSS animation to make it. Like this-
HTML-
<div class="div"></div>
And CSS-
<style>
.div{
width:100px;
height:100px;
background:red;
animation-name:opacity;
animation-duration:4s;
}
#keyframes opacity{
0%{opacity:0;}
100%{opacity:1;}
}
</style>
U can simply use CSS animations instead of transition.
consider HTML code having single div element
<div id="main"></div>
now to apply CSS animation we do something like this,
#main{
...add your desired code for styling the div...
animation-name:onload;
animation-duration: 1s;
animation-delay: 2s; //this is the key line, what this means is the animation would start after 2s of delay.
}
// Now creating animation
#keyframes onload{
0%{
opacity:0;
}
100%{
opacity: 1;
}
}

How to create an ease-in-out for image hover replacement in html?

Here is the image replacement code I am currently using in various parts of our website, to do a hover image replacement. My question is how to add an ease-in-out .5s to the existing code, or an alternative CSS code to our stylesheet for use throughout our website. I am looking to create a smoother transition between images. Thank you in advance for your help.
<img src="https://gingerhippo.com/wp-content/uploads/2018/04/GingerHippo-Search-Services-3-1.jpg"
onmouseover="this.src='https://gingerhippo.com/wp-content/uploads/2018/04/Ginger-Hippo-Search-Services-1-1.jpg'"
onmouseout="this.src='https://gingerhippo.com/wp-content/uploads/2018/04/GingerHippo-Search-Services-3-1.jpg'"
>
On our home page, you will see 7 different image hover replacement images, all with no transition timing. I've managed to create background transitions for what looks like buttons on our blog and industry articles pages, but can't replicate the process for our main page imagery.
Thank you again in advance for your help. I've been stuck on this for a couple of months.
Put the two images in an outer block element.
<section>
<img class="bottom" src="img.png">
<img class="animation" src="img-2.png">
</section>
The outer will be relative and the inner will be absolute.
section {
position: relative;
}
section img {
position: absolute;
}
Create the animation and apply it to the top element.
.animation {
animation-name: fade;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 1s;
animation-direction: alternate;
}
#keyframes fade {
0% {
opacity: 1;
}
25% {
opacity: 1;
}
75% {
opacity: 0;
}
100% {
opacity: 0;
}
}
Now if you want to edit the animation effect make changes in .animation.
Source: https://www.taniarascia.com/crossfade-between-two-images-with-css-animations/
You can also use this Example
var $this = $(this);
var newSource = $this.data("alt-src");
$this.data("alt-src", $this.attr("src"));
$this.attr("src", newSource);
};
$(function() {
$("img.demo-img").hover(sourceSwap, sourceSwap);
});
<img class="demo-img" data-alt-src="image-2.png" src="image-1.png" />

How to correct Hover css effect tremble/shaking?

I made an hover effect in my website that references an image that is the original image in 65% of opacity. The problem is, and this only happens one time, only the first time i hover it everything shakes/tremble a bit, but then everything starts working just fine. Perhaps something missing in my hover code? Can you see what's wrong?
Thanks for the help :)
The css code I'm using:
#rebface
{
content:url("http://static.tumblr.com/g1c47pc/Td2n783c4/nface.png");
position:relative;
left:8%;
margin-left:20px;
display:block;
box-sizing: border-box;
}
#rebface:hover {
content:url("http://static.tumblr.com/g1c47pc/alcn783j0/nface_65.png");
transition: 0.5s linear;
position:relative;
display: block;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
The HTML:
<div style="margin-top:20px; display:flex;">
<a target="_blank" href="http://www.facebook.com/sharer.php?u={Permalink}"><div id="rebface"></div></a>
</div>
You can see it here: (This website only works in chrome/safari for now)
http://testedesignfranjas.tumblr.com/post/87336302788/blend-food-culture-magazine-concepcao-de
You are swapping the images in the CSS content attribute. I'm quite sure these arent cached on page load so they are loaded when hovering what causes a short flickering.
You can simply avoid that by using opacity instead of another image.
.facebook
{
content:url("http://static.tumblr.com/g1c47pc/jhDn7hp40/sitef_1.png");
left:50px;
z-index:2;
position:absolute;
top:110px;
left:0px;
z-index:50;
}
.facebook:hover {
opacity: 0.6;
-webkit-backface-visibility: hidden;
}
And as a side note -- use background instead of adding a background image via the content attribute. It works for older browsers and is much more of a best practice.
In your css you have the following:
#rebtweet:hover{ some-styles }
#rebface:hover{ some-styles }
#rebtumb:hover{ some-styles }
#rebgplus:hover{ some-styles }
Each of these has one common style: transition: 0.5s linear;
Try removing this style. I'm not sure, but it may solve your flickering issue.
Hope this helps.

CSS line-height transition issue in firefox (a bug?) [duplicate]

I've found annoying bug. I try to animate CSS properties of child elements when at the same time position of parent is changing (in the example it's from fixed to absolute). This works without problem in Webkit browsers, but in Firefox (v. 17.0.1) there's no animated transition.
jsFiddle example: http://jsfiddle.net/chodorowicz/bc2YC/5/
Is there any solution to make it work in FF?
EDIT
It's fixed in Firefox 34
https://bugzilla.mozilla.org/show_bug.cgi?id=625289
CSS
#container {
position:fixed; left:100px; top:100px;
}
#container.some_state_position {
position:absolute;
}
.box {
width:100px; height:100px;
background:blue;
}
.some_state .box {
background:red; width:50px; height:50px;
}
img, .box {
-webkit-transition:all 1.5s ease;
-moz-transition:all 1.5s ease;
-ms-transition:all 1.5s ease;
transition:all 1.5s ease;
}
img {width:100%;}
.some_state .other_container img {
width:50%;
}
It seems you have found a good bug. Although this isn't my favorite fix, it does the job. Change your button2 to do this on click.
$("#button2").on({
click: function() {
$("#container").toggleClass("some_state");
setTimeout(function() {
$("#container").toggleClass("some_state_position");
}, 50);
}
});
It appears for firefox the toggleClass() fires immediately for both classes, causing some issues with the transition effects. Putting the timeout gives jQuery the enough time for it to process what it needs to, in order to do the transitions similar to those in Chrome, etc. I put the timeout to 50ms, this appears to give it enough time for jQuery to process what it needs to do. Going lower than that I saw sometimes, it fail and do what you are currently experiencing.

navigation with cross fading images html5 css3

i'm trying to set up a navigation with cross fading images besides the nav. But placing the between the is not working.
So my intention is if home, about, work or contact is clicked the( one page ) will load the content and the navigation shows the right image of the current page.
HTML: <div id="cf7" class="shadow">
<img class='opaque' src="/images/Cirques.jpg" />
<img src="/images/Clown%20Fish.jpg;" />
<img src="/images/Stones.jpg;" />
<img src="/images/Summit.jpg;" />
</div>
<p id="cf7_controls">
<span class="selected">Home</span>
<span>About</span>
<span>Work</span>
<span>Contact</span>
</p>
CSS
p#cf7_controls {
text-align:center;
}
#cf7_controls span {
padding-right:2em;
cursor:pointer;
}
#cf7 {
position:relative;
height:281px;
width:450px;
margin:0 auto 10px;
}
#cf7 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;
opacity:0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
}
#cf7 img.opaque {
opacity:1;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=1);
}
JAVASCRIPT
$(document).ready(function() {
$("#cf7_controls").on('click', 'span', function() {
$("#cf7 img").removeClass("opaque");
var newImage = $(this).index();
$("#cf7 img").eq(newImage).addClass("opaque");
$("#cf7_controls span").removeClass("selected");
$(this).addClass("selected");
});
});
That's a very unusual way to build a navigation. You don't even use anchor tags; those have the highest compatibility with older browsers for states like :hover.
For your example you need a syntax like this, for displaying the right images:
<span>About</span>
span {
background-image: none;
}
span#your_span_id:hover, span.selected {
background-image: url('path/to/your/img');
}
However, if you want to load content on one page, you will need at least javascript/ jquery to dynamically add/remove the '.selected' class. One CSS workaround is to nest your content divs in the navigation (and display: hide them, on hover show them), but in that case you need to specify the cursor for every element inside your content divs, and as soon as your visitors mouse out of the content div, it will disappear. Click events= javascript