简体   繁体   English

jquery div隐藏和显示,如何控制show div的position?

[英]jquery div hidden and show, how to control show div's position?

I make an easy div hover show and hide introduce words with jQuery, in the default code.我做了一个简单的 div hover 显示和隐藏 jQuery 的introduce words ,在默认代码中。 All the introduced words position is relative.所有引入的字 position 都是相对的。 the introduce words div's of box4 and box8 will out of the div#main . box4box8introduce words div 将超出div#main

and how to do?怎么办? so that the introduce words div of box4 and box8 will make a right align?这样box4box8的引入词div会右对齐吗?

For I can not describe well in english, I make a picture.因为我不能用英语很好地描述,所以我拍了一张照片。 you can see when hover in box4 , the introduce words div's right will not out of the div#main , this is what I need.你可以看到当 hover 在box4中时,div 的introduce words右边不会超出div#main ,这就是我需要的。 Thanks.谢谢。

code link here: http://jsfiddle.net/KTGUz/代码链接在这里: http://jsfiddle.net/KTGUz/

image:图片:我想要的是这样的

Pure jQuery way is $('.box:nth-child(4n+4)').addClass('oy');纯 jQuery 方式是$('.box:nth-child(4n+4)').addClass('oy'); and adjust your positioning to make the .box relative and the .hover absolute, making .oy {right: 0;}并调整您的位置以使.box相对而.hover绝对,使.oy {right: 0;}

Here's the stuff: http://jsfiddle.net/3jGdm/这是东西: http://jsfiddle.net/3jGdm/

You could give boxes 4 and 8 a different class if you know they're going to always be on the edge.你可以给盒子 4 和 8 一个不同的 class 如果你知道它们总是在边缘。 Here's an example:这是一个例子:

http://jsfiddle.net/M687z/ http://jsfiddle.net/M687z/

If it depends on the window width how many boxes are in a row you can use the jQuery.offset() feature to reposition the title_box if it would overflow:如果它取决于 window 宽度,一行中有多少个框,您可以使用 jQuery.offset() 功能重新定位 title_box 如果它会溢出:

http://api.jquery.com/offset/ http://api.jquery.com/offset/

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

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