2
I created a small image gallery using this structure:
<div class="slider">
<div class="dest">
<img src="http://www.imagebrowse.com/wp-content/uploads/2013/08/astonishing-aristic-mobile-background-wallpaper-background.jpg" alt="suites-slider-dest">
</div>
<div class="navbar">
<img src="http://www.imagebrowse.com/wp-content/uploads/2013/08/marvellous-water-drops-background-2013.jpg">
<img src="http://www.imagebrowse.com/wp-content/uploads/2013/08/marvelous-beautiful-autum-tree-wallpaper-background.jpg">
</div>
With the CSS:
img
{
max-width: 100%;
}
.slider
{
display: inline-block;
padding: 75px 0;
}
.dest img
{
border: 5px solid #fff;
box-shadow: rgba(0,0,0,0.5) 0 0 15px;
float: left;
margin-right: 15px;
width: 70%;
}
.navbar
{
float: left;
margin-left: 10px;
width: 17%;
}
.navbar img:first-child
{
margin-top: 0 !important;
}
.navbar img
{
border: 5px solid #fff;
box-shadow: rgba(0,0,0,0.5) 0 0 15px;
cursor: pointer;
display: block;
margin-top: 15px;
opacity: 0.5;
}
.navbar img:hover
{
opacity: 1;
}
And the Jquery:
$(".navbar img").click(function()
{
var dest = $(".dest img").attr('src');
var icon = $(this).attr('src');
$(this).removeAttr('src');
$(this).attr('src', dest);
$(".dest img").removeAttr('src');
$(".dest img").attr('src',icon);
});
The code is functional but I need the image transition inside the div with the "dest" class to be smooth. How can I do this?
Still the transition is not smooth. How could it achieve this effect?
– João Paulo Saragossa
@Joãopaulosaragossa Work out what you mean by soft! Want a visual effect? Like Fade and appear softly?
– Zuul
Exactly, as if it were a fade out/fade in. I tried to incorporate these functions into the code but did not succeed.
– João Paulo Saragossa
Okay, I’ll change the answer, but I have to fix your HTML.
– Zuul
@Joãopaulosaragossa I updated the answer with a version containing the effects.
– Zuul
For some bizarre reason the effects are not happening when I integrate the code on my page, I suspect it must be something in CSS, which already counts 629 lines. Anyway your code is functional so I’ll flag the question as answered.
– João Paulo Saragossa