如果 html 元素位于 div 的溢出区域且溢出属性设置为隐藏,如何检查该 html 元素是否可见?
我有一组 LI 元素,其溢出属性设置为隐藏
jCarouselLite 插件。我想做的事 是滚动 jCarouselLite'd 元素以便滚动到 我想要 LI 元素,因为我已将其配置为 仅显示 3 个元素。 查看插件生成的 html 代码,我可以看到:
<ul ..>
<li ..style="..overflow:hidden">1</li>
<li ..style="..overflow:hidden">2</li>
<li ..style="..overflow:hidden">3</li>
<li ..style="..overflow:hidden">4</li>
</ul>
因此,我有插件显示的前 3 个 LI 元素,但没有最后一个。我想做的是滚动以便显示第四个 LI 元素,或者如果我设法检查最后一个 LI 是否在溢出区域内,我可以自己执行此操作,这样我就可以看看是否有必要滚动为了显示或不显示它。
希望我不会让事情变得混乱而难以理解。
I have a set of LI elements with overflow propety set to hidden by the
jCarouselLite plugin. What I would like to do
is to scroll the jCarouselLite'd element in order to scroll to the
LI element I want, since I have it configured to
show only 3 elements.
Looking at the html code generated by the plugin, I can see:
<ul ..>
<li ..style="..overflow:hidden">1</li>
<li ..style="..overflow:hidden">2</li>
<li ..style="..overflow:hidden">3</li>
<li ..style="..overflow:hidden">4</li>
</ul>
So, I have the first 3 LI elements shown by the plugin, but not the last one. What I would like to do is to scroll so that the 4th LI element is shown, or I can do that by myself if I manage to check if that last LI is within the overflow area, so I can see if it's necessary to scroll for it in order to show it or not.
Hope I'm not getting things confused to understand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,您想检查该组中的最后一个 li 是否具有样式溢出:隐藏。
您可以使用一个简单的选择器来完成此操作。
这会将最后一个li的溢出样式设置为变量“tester”,并且当它发送警报框时,它将警告当前溢出状态。因此,如果溢出设置为隐藏,则会显示“隐藏”,如果溢出设置为滚动,则会显示“滚动”。
抱歉,如果我没有正确理解或回答您的问题。
If I understand you correctly, you want to check if the last li in that group has the style overflow: hidden.
You can do this with a simple selector.
That will set the last li's overflow style to the variable "tester", and when it sends the alert box it will alert the current state of overflow. So if overflow is set to hidden, it will say "hidden", if overflow is set to scroll it will say "scroll".
Sorry if I didn't understand properly or answer your question.
我找不到原始问题的答案,但对于任何 jCarouselLite 插件用户,为了使 carouselLite 滚动到特定项目,我所做的就是修改私有方法 go< 的声明/strong> 插件以便将其公开,如下所示:
我确信这不是最好的,更重要的是,更安全的解决方案,但目前它对我有用。只需调用
我的脚本,将位置视为从 0 开始的数字(carouselLite 上的第一个位置)。
I couldn't find an answer for my original question, but as for any jCarouselLite plugin users, what I did in order to make the carouselLite scroll to a particular item, was to modify just the declaration of the private method go of the plugin in order to make it public, as follows:
I'm sure it's not the best, and more importantly, safer solution, but for now it works for me. Just have to call
on my script, considering position as a number starting from 0 (the first position on the carouselLite).