简体   繁体   English

在悬停问题上显示div

[英]Show div on hover issue

In this fiddle you will fill when i hover on "action" a dropdown is showed. 在这个小提琴中,当我将鼠标悬停在“动作”上时,将显示一个下拉列表。

The problem is when we see the last item it goes below the scroll and it is not seen. 问题是,当我们看到最后一个项目位于滚动条下方且没有看到时。 in .scrollable class i have used the position:relative; .scrollable类中,我使用了position:relative;

.scrollable
{
    overflow: auto;
    height: 300px;
    position:relative;
    width:100px;    
}

and the child class "drop" has the position:absolute; 子类“ drop”的position:absolute;

i dont want to change the position:relative of .scrollable class and i want the .drop element to comeout of the scrollable on hover and .drop should not be shown below the scroll; 我不想更改position:relative对于.scrollable类的position:relative ,并且我希望.drop元素在悬停时会出现可滚动的内容,并且.drop不应显示在滚动下方;

here is the fiddle : http://jsfiddle.net/napper7/XPxsx/15/ THanks in advance!! 这是小提琴:提前http://jsfiddle.net/napper7/XPxsx/15/谢谢!!

here is a working code,i added a bit of js to get the current cursor position 这是一个工作代码,我添加了一些js来获取当前光标位置

$('.navItem').each(function() {
    $(this).hover(function(e) {
       $(this).find(".drops").css('left',e.pageX-20);   
       $(this).find(".drops").css('top',e.pageY);            

    }, function(e) {});
});​

http://jsfiddle.net/XPxsx/43/ http://jsfiddle.net/XPxsx/43/

    .scrollable
{      
    position:relative;
    height:300px;
    width:100px;    
}​

I think your best bet is to drop off the overflow behavior. 我认为您最好的选择是放弃溢出行为。 As far as I know, it is not possible to display nested divs outside their parent when it has an overflow value different from visible. 据我所知,当它的溢出值不同于可见值时,不可能在其父级外部显示嵌套的div。 Ever other values clip the outside box content of some sort (either by adding a scrollbar or by hiding completely the content) 其他任何值都会裁剪某种形式的外框内容(通过添加滚动条或完全隐藏内容)

I edited a jsfiddle that does what you want but without a scrollbar : http://jsfiddle.net/XPxsx/42/ 我编辑了一个jsfiddle来实现您想要的功能,但是没有滚动条: http : //jsfiddle.net/XPxsx/42/

And here is some documentation on overflow behavior : http://www.w3.org/TR/CSS21/visufx.html 这是有关溢出行为的一些文档: http : //www.w3.org/TR/CSS21/visufx.html

Anything out of this, will be using js to display the content in a different place DOM wise. 除此之外,都将使用js在DOM明智的地方显示内容。

Also, as a more general opinion : it is good to use sass (i guess from css indentation), but even better to order your selectors in a meaning order, that would be from the most general to the most specific (such as html, then body, then div.. in your case .scrollable, then .actionTools, then .navItem..) 另外,更普遍的看法是:最好使用sass(我猜是从css缩进中得出),但最好按含义顺序排列选择器,从最一般到最具体(例如html,然后是正文,然后是div。(在您的情况下为.scrollable,然后是.actionTools,然后是.navItem ..)

hope that helps 希望能有所帮助

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

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