简体   繁体   English

扩展盒

[英]Expanding and covering boxes

I am looking forward to find a jQuery code that allows me to have the following behaviour (in the pictures). 我期待找到一个jQuery代码,该代码可让我具有以下行为(在图片中)。 So I have a grid as shown below and if someone clicks on the red area (a DIV), that div will cover (go over the top) the boxes around it (two boxes from right or left side, one underneath or at the top) And if he clicks again, the div goes back to its normal position and size I can't figure out how do I achieve this? 因此,我有一个如下所示的网格,如果有人单击红色区域(DIV),则该div将覆盖(越过顶部)其周围的框(从右侧或左侧两个框,一个位于下方或顶部) )如果他再次单击,则div将恢复到其正常位置和大小,我不知道该如何实现? I would appreciate if someone can help please. 如果有人可以帮助,我将不胜感激。

Stage 1: http://img341.imageshack.us/img341/461/stage1.jpg 阶段1: http//img341.imageshack.us/img341/461/stage1.jpg

在此处输入图片说明

Stage 2: http://img153.imageshack.us/img153/9601/stage2n.jpg 阶段2: http//img153.imageshack.us/img153/9601/stage2n.jpg

在此处输入图片说明

This took me longer than I would care to admit: 这花了我比我愿意承认更长的时间:

http://jsfiddle.net/d4DZd/ http://jsfiddle.net/d4DZd/

The trick is to clone the element and grow that one instead of the original so that the elements keep their position. 诀窍是克隆元素,并扩大该元素而不是原始元素,以使元素保持其位置。

Like this? 像这样?

http://jsfiddle.net/kbPqU/ http://jsfiddle.net/kbPqU/

$(".box-spec").click(function() {
    var cover_width = 3,cover_height = 3;
    $("body").prepend('<div class="box-spec" style="width:' + ((128 + 10) * cover_width) + 'px;height:' + ((128 + 10) * cover_height) + 'px"></div>');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM