使用 html、css 切换每个 div 标签的可见性的最简单幻灯片
我有几个包含简单 html/css 内容的 div 标签,我需要一种简单的方法让查看者单击链接“幻灯片 1”,该幻灯片的第一个 div 标签变得可见,然后他们单击幻灯片 2,第二个 div 标签是可见,等等。
我尝试在 Dreamweaver 中使用时间线,但这似乎太过分了,而且太复杂了。引入整个 YUI 库也是如此。我们只需要一个基本的、强力的方法,即在单击链接时使其可见/不可见。
所以设置是
<LINK_SLIDE1> <LINK_SLIDE2> <LINK_SLIDE3>
<div class="slide" id="slide1">
<p>Welcome etc etc etc</p>
</div
<div class="slide" id="slide2">
<p>Overview etc etc etc</p>
</div
<div class="slide" id="slide3">
<p>Summary etc etc</p>
</div
我正在寻找一些关于如何实现链接来打开/关闭每个 div 标签的可见性的提示。我担心的一个问题是,如果用户没有启用 JavaScript,我们也可以处理这种情况吗?
I have several div tags containing simple html/css content and I need a simple way for a viewer to click a link 'Slide 1' and the first div tag for that slide become visible, then they click slide 2 and the second div tag is visible, and so on.
i tried using timelines in Dreamweaver but that seems like overkill and far too complex. So is pulling in the whole YUI library. Just a basic, brute force, make visible/invisible when a link is clicked is all we need.
so the setup is
<LINK_SLIDE1> <LINK_SLIDE2> <LINK_SLIDE3>
<div class="slide" id="slide1">
<p>Welcome etc etc etc</p>
</div
<div class="slide" id="slide2">
<p>Overview etc etc etc</p>
</div
<div class="slide" id="slide3">
<p>Summary etc etc</p>
</div
And I'm looking for some tips on how to implement the LINKs to toggle the visiblity of each div tag on/off. One problem I'm worried about is if a user doesnt have javascript enabled, can we handle that case too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用户单击链接时的基本流程应该是:
您可以通过向每个链接添加事件侦听器,然后确定单击了哪个链接以及显示哪张幻灯片来实现此目的。对于此类问题,使用链接中的
rel
属性是存储此信息的快速方法。这是一个不使用任何框架的示例,我还没有对其进行测试。仅举一个例子。
以及与之配套的 HTML 示例:
希望这能让您走上正轨。
The basic flow when the user clicks the link should be:
You can do this by adding event listeners to each link, then figuring out by which link was clicked, which slide to show. For problems like this using the
rel
attribute in the link is a quick way to store this info.Here's an example using no framework whatsoever, and I haven't tested it. Just for an example.
and example HTML to go with it:
Hopefully that can get you on the right track.
有一个名为 S5 的非常棒的预构建开源实现。看看吧,你可能会非常喜欢它。
There's an awesome, pre-built, open-source implementation called S5. Take a look, you'll probably really like it.