Suppose I've 10 divs
in the form of squares
. Lets call it the home
page.
Out of these 10,
3 divs
have class .event1
5 divs
have class .event2
2 divs
have class .event3
<div class="boxes event1">
....//3-times
....
</div>
<div class="boxes event2">
....//5-times
....
</div>
<div class="boxes event3">
....//2-times
....
</div>
The boxes are placed next to one another.
When I click event1
, all box fadeout except those having the class event1
. Similarly, for all classes. On clicking home
, all boxes will again fade in.
<div id="navi">
<a href="#"><div id="t0"><span>Home</span></div></a>
<a href="#"><span>Event1</span></a>
<a href="#"><span>Event2</span></a>
<a href="#"><span>Event3</span></a>
</div>
My JQuery code for fadeOut
:
<script type="text/javascript">
$(function () {
$('#t0').click(function() {
$("*").animate({
opacity: 1.0
}, 500 );
});
$("#navi a").click(function() {
c = $(this).text().toLowerCase();
if (c!="home"){
$('.' + c).animate({
opacity: 1.0
}, 500 ).addClass('w1');
$('.boxes').not('.' + c).animate({
opacity: 0.0
}, 500 );
}
});
});
</script>
CSS for the classes:
.boxes, .event1, .event2, .event3 {
background:rgba(0, 0, 0, .30);
float:left;
position:relative;
overflow:hidden;
width:100px;
height:100px;
margin:2px;
box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
-moz-box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
-webkit-box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
}
.w1:hover{
background:rgba(0, 0, 0, .30);
float:left;
width:200px;
height:200px;
position:absolute;
overflow:hidden;
box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
-moz-box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
-webkit-box-shadow:0 0px 15px rgba(0,0,0,0.75) inset;
}
Now I want to make only a particular box increase in size (width:200px; height:200px
), when the mouse pointer is hovered. I can't find a way to do it.
When I'm adding the class .w1
in javascript
code, it is being applied to all the elements having class event1
or event2
or event3
(whichever one was selected). So, when I'm hovering to a particular box of that class (which was selected), all the boxes undergo transition and the boxes shift.
I want only one box to change dimensions while the other boxes are at their original place.
Also, this hovering
event has to be activated for a particular event so that one can't hover
on elements when home
is selected. I even tried doing this by changing z-index
but the page got pretty messed up.