滚动条经常出现,当我将鼠标移到某些特定的Div上时

问题描述:

亲爱的,



滚动条经常出现,而我鼠标悬停在一些特定的div上,但我已经检查过其他屏幕没有问题,因为我看到了,所以任何人都可以帮我解决这个问题



提前谢谢



Velsamy

Dear all,

scroll bar is coming often , while i mouse over on some specific div, but i have checked with other screens there is no problem as i seen, so anyone could help me to solve this

thanks in advance

Velsamy

您遇到的问题是与样式相关的问题。当您将鼠标悬停在某个元素上时,该元素会获得更多边框或填充或边距。这会导致其大小发生变化。在这种情况下,它的大小会放大,导致滚动条出现。



有一些黑客为此,第一个是确保身体元素总是占用屏幕的一部分,像这样



The problem that you're having is a style related issue. When you hover over to some element, the element gets some more borders or paddings or margins. Which causes its size to be changed. In this case, its size enlarges causing the scroll bar to come out.

There are some hacks for this, first one is to make sure the body element always takes up a part of the screen, like this

// set the body's height to be the 100 less than the screen's height..
document.getElementById("body").style.height = screen.height - 100;





..或者你可以使用CSS解决这个问题,你可以确保在任何悬停事件(鼠标悬停)上对象的大小不会改变。



..or you can use the CSS to tackle this, and you can make sure that upon any hover event (mouse over) the size of the objects don't change.