Reputation: 3
I have a simple jquery gallery that I am trying to create.
I have it working except, when you click on the thumbs - it does this:
Does anyone know how I can fix this with CSS or Jquery?
I am try to make this super simple.
Thanks
here is the jsfiddle: http://jsfiddle.net/webdott/zZNBQ/1/
<div>
<img src="image1.jpg" class="first"/>
<img src="image2.jpg" />
</div>
<style>
img {float:right;width:10%;margin:1%;}
.fullview{width:60%;margin:0 4% 0 0;float:left;}
.first{width:60%;margin:0 4% 0 0;float:left}
</style>
<script>
$('img').click(function() {
$(this).addClass('fullview').siblings().removeClass('fullview first');
});
</script>
Upvotes: 0
Views: 268
Reputation: 11210
I think the problem is that the images before and after the one which is selected are affecting how the larger one displays and is floated. How about floating a large image as a single element, then changing the source of that element to match the clicked element? Like this example.
$('.thumbnail').click(function() {
var src = $(this).attr('src');
$('#fullview').attr('src',src);
});
and
#fullview {
float:left;
max-width:75%;
}
ul {
float:right;
}
li {
display: inline;
}
li img {
width:50px;
cursor: pointer;
}
or you could do something similar but with the gallery on the side like this example.
Upvotes: 0