纯CSS滑块
我正在尝试获取一个纯 css 滑块 (http://jsfiddle.net/trN4p/1/) 使用 :target
在同一文档/页面上的另一个纯 css 滑块中进行操作,以对每个滑块进行独立控制进行导航。
这是问题的示例: http://jsfiddle.net/J6htH/4 /
我希望内部(CHILD)滑块独立于外部(PARENT)滑块并与外部(PARENT)滑块一起工作(无冲突)。
我想知道是否有一种方法可以将内部(CHILD)滑块分开两个滑块,以便他们的列表项目(和哈希标签)相对于滑块而不是整个页面/dom 进行操作?是否有一些 jQuery/Ajax 魔法或 JS 模板(主干/下划线) 技巧来做到这一点?
I'm trying to get one pure css slider (http://jsfiddle.net/trN4p/1/) to operate within another pure css slider on the same document/page using :target
for navigation with independent control for each slider.
Here is an example of the problem: http://jsfiddle.net/J6htH/4/
I want the inside (CHILD) slider to work independently of and alongside (w/out conflict) the outside (PARENT) slider.
I was wondering if there is a way to separate the two sliders so that their list items (and hash tags) operate relative to the slider and not the whole page/dom? Is there some jQuery/Ajax magic or JS templating (backbone/underscore) tricks to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不想这么说(因为我理解用纯 CSS 制作非常酷的东西是多么棒的感觉),但你应该使用 JavaScript。
请耐心听我说,如果你觉得我不合理,请评论:
你只能有一个与
:target
匹配的元素,因为你只能有一个主题标签,所以你最多可以有每次将一个滑块设置为特定项目(另一个将返回默认值)。无论你喜欢与否,这就是约束。另一方面,HTML+CSS+JS 是模型-视图-控制器模式/模型/概念的一个很好的例子。
Model
,因为它包含所有data
View
,因为它包含所有styles
控制器
,因为它定义了用户
、数据和样式如何交互
。您正在尝试制作一个涉及用户交互的滑块。触发事件(如
点击
)实际上应该由控制器
处理,而不是视图
。tl;dr:
您无法在纯 CSS 中执行您所描述的操作。
I hate to say it (because I understand how awesome it feels to make really cool things in pure CSS), but you should use JavaScript.
Bear with me here, and comment if you feel i'm being unreasonable:
You can only have a single element that's matched as
:target
, because you can only have one hashtag, so at most you can have one slider set to a particular item at a time (the other would return to default). This is the constraint, whether you like it or not.On the other hand, HTML+CSS+JS is a great example of the Model-View-Controller pattern/model/concept.
Model
as it contains all thedata
View
as it contains all thestyles
Controller
as it defines how theuser
, data and stylesinteract
with each other.You're trying to make a slider which involves user interactions. The triggering events (like
click
) should really be handled by theController
, not theView
.tl;dr:
You can't do what you're describing in pure CSS.
我只知道一个滑块,但它是网站构建器的一部分。
在这里您可以看到演示版本的链接:https://mobirise.com/extensions/wowslider/?utm_source=extension_list&utm_medium=program&utm_campaign=win_4.8.8
如果你想使用滑块,可以在项目中创建它,然后获取代码并粘贴到您自己的网站。
I know only one slider but it's a part of the website builder.
Here you can see the link to you to demo version: https://mobirise.com/extensions/wowslider/?utm_source=extension_list&utm_medium=program&utm_campaign=win_4.8.8
If you want to use a slider, you can create it within the project and then take a code and paste to your own website.