Increasing Dimensions On Hover Without Changing The Position Of Other Elements
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
Solution 1:
I felt free to rebuild your project. Instead of css i use javascript in this example. The main point of this example is, that i do not resize the existing box. I build a new div, copy the content of the old div, position it absolute and set the opacity of the old one to 0. jsfiddle link: http://jsfiddle.net/56yeQ/8/
html:
<divid="navi"><ahref="#"><divid="t0"><span>Home</span></div></a><ahref="#"><span>Event1</span></a><ahref="#"><span>Event2</span></a><ahref="#"><span>Event3</span></a></div><divclass="boxes event1">
1
</div><divclass="boxes event1">
2
</div><divclass="boxes event1">
3
</div><divclass="boxes event2">
4
</div><divclass="boxes event2">
5
</div><divclass="boxes event2">
6
</div><divclass="boxes event2">
7
</div><divclass="boxes event2">
8
</div><divclass="boxes event3">
9
</div><divclass="boxes event3">
10
</div>
css:
.boxes, .event1, .event2, .event3 {
background:rgba(0, 0, 0, .30);
float:left;
position:relative;
overflow:hidden;
width:100px;
height:100px;
margin:2px;
box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-moz-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-webkit-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
}
.w1{
background:rgba(0, 0, 0, .30);
float:left;
width:100px;
height:100px;
position:absolute;
overflow:hidden;
margin: 2px;
box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-moz-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-webkit-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
opacity: 1;
}
javascript:
var isHome = true;
$(function () {
$("#navi a").click(function() {
c = $(this).text().toLowerCase();
isHome = c=="home";
if (isHome){
$("*").animate({
opacity: 1.0
}, 500 );
} else {
$('.boxes').not('.' + c).animate({
opacity: 0.0
}, 500 );
$('.' + c).animate({
opacity: 1.0
}, 500 )
}
});
});
functionhoverIn(element){
if(!isHome && $(this).css("opacity")==1){
$(".w1").each(function(i){
var oldDiv= $(this).data("oldDiv");
$(oldDiv).css({opacity:1});
$(this).remove();
});
var posX = $(this).position().left+2;
var posY = $(this).position().top+2;
var newDiv = $("<div>").html($(this).html());
$(newDiv).mouseleave(hoverOut);
$(newDiv).addClass("w1");
$("body").append(newDiv);
$(this).css({opacity: 0});
$(newDiv).offset({top:posY, left: posX});
$(newDiv).data("oldDiv",this);
$(newDiv).animate({height:"200px",width:"200px"},500);
}
}
functionhoverOut(element){
var oldDiv= $(this).data("oldDiv");
$(oldDiv).css({opacity:1});
$(this).remove();
}
$(".boxes").mouseenter(hoverIn);
Solution 2:
Maybe this is what you are looking for:
.w1:hover{
<!--Removed the position absolute-->
background:rgba(0, 0, 0, .30);
float:left;
width:200px;
height:200px;
overflow:hidden;
box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-moz-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
-webkit-box-shadow:00px15pxrgba(0,0,0,0.75) inset;
margin-bottom: -100px;
}
.w1:hover +div{
margin-left: -100px;
}
Post a Comment for "Increasing Dimensions On Hover Without Changing The Position Of Other Elements"