Javascript鼠标滚轮事件滚动(Javascript mousewheel event scroll)
我有以下http://jsfiddle.net/o0krp0yf/基本上如果我用鼠标滚轮滚动,停止它(我想滚动幻灯片)。 但我的问题是,如果我有一个具有正常滚动行为的元素,我无法滚动该元素(请参阅
.scroll
)。无论如何检测一个元素(光标已经结束,即我想滚动该元素)是可滚动的还是有滚动条,如果是,我想要正常滚动该元素。
基本上我想让我的常规方法完美地工作,除非我试图滚动
.scroll
元素。I have the following http://jsfiddle.net/o0krp0yf/ basically if I scroll with mouse wheel, stop it (I want to scroll slides). But my problem is if I have an element with normal scroll behavior I have no way of scrolling that element (see
.scroll
).Is there anyway to detect if an element (which the cursor is over, ie I want to scroll that element) is scrollable or has scrollbars, and if it does I want to scroll that element normally.
Basically I want to allow my normal method to work perfectly, unless I am trying to scroll
.scroll
element.
原文:https://stackoverflow.com/questions/26770304
最满意答案
你可以用CSS做到这一点,但它需要一个hacky解决方案,具有令人惊讶的良好浏览器支持 。
基本上,我们的想法是使用CSS计数器来计算所需列表项的项目数(用类标记):
<div class="numbered-stuff"> <p> If you want the important stuff, skip to step </p> <ol> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li class="important">Important Stuff</li> <li>Stuff</li> </ol> </div>
在这种情况下,我们将第5个项目标记为我们的类,因此我们需要在它之前为每个项目递增计数器:
ol { counter-reset: stuff; } ol li { counter-increment: stuff; } ol li.important:after{ content:counter(stuff); }
安静简单吧? 现在我们只需要在文本旁边放置
after
元素。 把它们放在一起(有点风格,因为丑陋的UI吮吸):@import url('https://fonts.googleapis.com/css?family=Lato'); body, html { margin: 0; background: #efefef; } .numbered-stuff { position: relative; display: inline-block; padding-right: 25px; font-family: 'Lato', sans-serif; } p { background: white; margin: 0; padding: 10px; } ol { counter-reset: stuff; } ol li { counter-increment: stuff; } ol li.important:after { content: counter(stuff); position: absolute; top: 0; right: 0; padding: 10px; color: white; background: #009688; } }
<div class="numbered-stuff"> <p> If you want the important stuff, skip to step </p> <ol> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li class="important">Important Stuff</li> <li>Stuff</li> </ol> </div>
当然,您可以根据需要更改html,但概念保持不变
You can do it with just CSS, but it takes a hacky solution, with surprisingly good browser support.
Basically, the idea is to use CSS counters to count the number of items to the list item you want(marked with a class):
<div class="numbered-stuff"> <p> If you want the important stuff, skip to step </p> <ol> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li class="important">Important Stuff</li> <li>Stuff</li> </ol> </div>
In this case, we have the 5th item marked with our class, so we need to increment the counter for every item before it:
ol { counter-reset: stuff; } ol li { counter-increment: stuff; } ol li.important:after{ content:counter(stuff); }
Quiet simple, right? Now we just need to position the
after
element beside the text. Putting it all together(With a little bit of style, because ugly UI's suck):@import url('https://fonts.googleapis.com/css?family=Lato'); body, html { margin: 0; background: #efefef; } .numbered-stuff { position: relative; display: inline-block; padding-right: 25px; font-family: 'Lato', sans-serif; } p { background: white; margin: 0; padding: 10px; } ol { counter-reset: stuff; } ol li { counter-increment: stuff; } ol li.important:after { content: counter(stuff); position: absolute; top: 0; right: 0; padding: 10px; color: white; background: #009688; } }
<div class="numbered-stuff"> <p> If you want the important stuff, skip to step </p> <ol> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> <li class="important">Important Stuff</li> <li>Stuff</li> </ol> </div>
Of course, you can change the html how you want, but the concept stays the same
相关问答
更多-
不要混淆List和数组。 一个数组有固定的位置和固定的大小,而列表则没有。 对于数组,不存在“添加”或“删除”项等内容。 数组始终具有创建它时分配的长度。 一个列表的长度是动态的。 您添加项目,列表增长。 您删除项目,列表缩小。 如果将项目添加到列表中,则该项目总是附加到列表中(您可以调用Insert以在指定位置插入)。 但是,在任何给定时间,列表中的条目都将具有从0开始范围到Count-1 (“基于零”)的索引。 即使您在位置X“在列表中间”移除了一个项目,该索引中也会有一个项目(之前位于X + 1的项目 ...
-
Django:请参阅model.save()方法中的上一项失败(Django: Refer to previous item in model.save() method fails)[2022-12-15]
几乎总是如此 - 这是我的错。 我从这个问题的另一种方法实施了重要的部分,这导致了这个问题。 无论如何,谢谢你试图帮助我。 Like almost always - it was my fault. I implemented vital part from another approach to this problem and this caused this issues. Thanks for trying to help me anyway. -
更改列表项(Change the list item)[2021-11-20]
在你的代码中: for (auto e: kids) { e._cuteKids.push_back("Jeck"); // Many some names... } 你正在复制 kids容器中的每个项目,同时迭代容器本身,因为你错过了一个“简单” & 。 所以,声明e._cuteKids.push_back(...); 正在复制 , 而不是在原始项目上。 每次循环迭代后,此本地副本“蒸发” ,并且子容器中的原始项目不受影响 。 您必须使用引用 ( & )正确迭代原始项目,以避免这些本地深层副本: ... -
获取嵌套列表项的索引(Get the index of a nested list item)[2023-06-13]
尝试这个: $('li').click( function() { var liIndex = $(this).index('li'); $(this).children().append(liIndex); }); http://jsfiddle.net/5zJD8/36/ 你可以在这里寻找更多的信息: http : //api.jquery.com/index/ Try this: $('li').click( function() { var liIndex = $(this). ... -
请参阅列表项(Refer to List item)[2022-03-28]
你可以用CSS做到这一点,但它需要一个hacky解决方案,具有令人惊讶的良好浏览器支持 。 基本上,我们的想法是使用CSS计数器来计算所需列表项的项目数(用类标记):If you want the important stuff, skip to step
- Stuff
- Stuff
- Stuff
- Stuff
如何使这个列表项“缩放”(How to make this list item “zoom”)[2022-04-19]
这是您想要的“缩放”效果吗? 您可以使用缩放变换以及变换原点来获得所需的缩放效果。 html, body { height: 100%; } div { perspective: 600px; width: 100%; height: 100%; background: red; display: flex; flex-direction: row; align-items: center; justify-content: center; } ...列表项中的一个空行(One blank line in list item)[2023-10-13]
表单在列表项中维护一个额外的NULL元素。 从在线帮助: 列表项和空值 ...设置弹出列表或TList的Required属性可能会影响列表将显示的值:选中此选项后,如果弹出列表的当前值为Null或其有效,则弹出列表的实例将显示一个额外的空值必需属性为false。 CLEAR_LIST内置清除列表项中的所有元素。 在Oracle Forms清除列表后,列表将只包含一个元素(null元素),而不管项目的Required属性如何。 Forms maintains an additional NULL elemen ...从列表项添加/删除类(add / remove class from list item)[2023-10-22]
根据点击的内容,它不会绘制焦点,也不会触发模糊事件。 你最好使用类选择器来获取项目。 $j('.item_list').on('click', function () { $j('.active_card').removeClass('active_card'); $j(this).addClass('active_card'); }); Depending on what is clicked, it won't draw focus and subsequently won't tri ...我在评论中问过你,但这些案例的解决方案通常是自定义列表字段迭代器来覆盖实际的“用户”控件,或者也可以添加自定义网站列,并在呈现时动态过滤其内容以将其挂接到列表 。 I asked you in the comments, but the solution to these cases are usually Custom List Field Iterators to override your actual "Users" control, or you can also add a custom sit ...如果你只关心listo2的第一个元素,你可以做类似的事情: def deleteList(listo1, listo2): for insidelist in listo1: if listo2[0] == insidelist[0]: listo1.remove(insidelist) print(listo1) def main(): deleteList([[1000, 1],[2000, 2],[3000, 3]], [1000, ...相关文章
更多- JavaScript 事件
- JavaScript 事件
- 解析JavaScript的事件机制
- storm事件管理器EventManager源码分析-event.clj
- Solr参数(DisMax Event Facet)
- javascript标准验证
- javascript 问题
- Phaser开源2d引擎 javascript/html5游戏框架
- javascript函数返回的一个奇怪的现象
- 请教javascript问题
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。