zoukankan      html  css  js  c++  java
  • 精准定位元素+解决浏览器窗口大小改变时,页面错位的问题

    首先,定位元素时,范围越小越精准,对其他页面的影响越小,

    所以,这个事件我没有用整个window,而是定位到了that.FormProp.mainTable这个元素,在设置样式时,也只设置了这个范围内的元素,

    比如:$(">div.vAction>.vActionSelect", that.FormProp.mainTable),这样写查找的更快,更精确。

    言归正传,加上以下代码,就能避免当窗口缩放时,页面出现错乱的现象。这样,盒子会随着窗口宽度的改变而调整自己的宽度。

    $(that.FormProp.mainTable).scroll(function () {
    let tops = parseInt($(">div.vAction>div.vActionSelect", that.FormProp.mainTable).css('top'));//To position the top value of the box
    tops = $(that.FormProp.mainTable).scrollTop() - 100;//Here, the top value of the box will change with the position of the scroll bar
    $(">div.vAction>.vActionSelect", that.FormProp.mainTable).css('top', top + 'px')//Finally, assign the top value to the box
    });

    点个赞吧
  • 相关阅读:
    Vasya and Endless Credits CodeForces
    Dreamoon and Strings CodeForces
    Online Meeting CodeForces
    数塔取数 基础dp
    1001 数组中和等于K的数对 1090 3个数和为0
    1091 线段的重叠
    51nod 最小周长
    走格子 51nod
    1289 大鱼吃小鱼
    POJ 1979 Red and Black
  • 原文地址:https://www.cnblogs.com/maleijiejie/p/14911773.html
Copyright © 2011-2022 走看看