简体   繁体   English

调整Div位置

[英]Adjusting Div position

I have a icon with onmouseover event handler. 我有一个带有onmouseover事件处理程序的图标。

On mouseover it displays a table. 在鼠标悬停时,它显示一个表格。 the Icon is at the right site of the screen. 图标位于屏幕的右侧。 If the table is small, it will be displayed within visible area. 如果表格很小,它将显示在可见区域内。 But if the the table is wide enough then only a part of the table is visible. 但是,如果表格足够宽,则只能看到表格的一部分。 One have to scroll to right to see the rest of the table. 您必须向右滚动才能看到表格的其余部分。

What would be the solution to display it. 显示它的解决方案是什么? I mean if the table will go 200px out of the visible area, then it should moved 200px to left. 我的意思是,如果表格将离开可见区域200px,那么它应该向左移动200px。

The table is displayed within an absolutlty positioned DIV. 该表显示在绝对位置的DIV中。

The div.left + div.clientWidth should be less than document.body.clientWidth. div.left + div.clientWidth应该小于document.body.clientWidth。 In other words, the furthest to the right (max value of div.left) on the screen your div can be can be calculated as: 换句话说,您的div可以在屏幕上最右边(div.left的最大值)计算为:

document.body.clientWidth - div.clientWidth

Give or take a pixel or two. 提供或占用一两个像素。

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

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