从单个连续的 HTML 页面移动到“单独的页面”。使用CSS
我有一个(有点长)单页网站,使用一些CSS(例如每个内容项都是一个div),我想将其移动到“一组单独的页面”,可以通过菜单进行导航。
因此,
<head>...</head>
<body>
<div>stuff</div>
<div>more stuff</div>
<div>even more stuff</div>
</body>
从用户的角度来看,我希望能够导航此内容,而似乎
<head>...</head>
<body>
<div>stuff</div>
</body>
<head>...</head>
<body>
<div>more stuff</div>
</body>
<head>...</head>
<body>
<div>even more stuff</div>
</body>
我应该将页面分成单独的页面,使用 jQuery 隐藏所有另一个
的还是有另一种更优雅的方法来实现这一点?I have a (somewhat long) single page website that uses some CSS (e.g. each content item is a div) I would like to move this to a "set of separate pages" which are navigable by means of a menu.
so instead of
<head>...</head>
<body>
<div>stuff</div>
<div>more stuff</div>
<div>even more stuff</div>
</body>
I'd like to be able to navigate this so from the user-perspective, it appears to be
<head>...</head>
<body>
<div>stuff</div>
</body>
<head>...</head>
<body>
<div>more stuff</div>
</body>
<head>...</head>
<body>
<div>even more stuff</div>
</body>
Should I just break up the page into separate pages, use jQuery to hide all the other <div>
's or is there another more elegant method of achieving this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这应该可以帮助您开始:
This should get you started:
很大程度上取决于上下文以及您实际呈现的内容,但如果您想要分解内容,有时选项卡式界面是一个可接受的解决方案。 jQuery UI 内置了一些Tab 功能,并且还有其他插件可以完成类似的功能。如果它是常见问题解答风格的界面,那么隐藏所有部分并在单击问题/标题时显示这些部分可能是有意义的,这可以通过 $("SOMETHING").toggle()$("SOMETHING").toggle() 在 jQuery.
A lot will depend on the context and what it is you're actually presenting, but if you're looking to break up the content, sometimes a tabbed interface is an acceptable solution. jQuery UI has some Tab functionality built in, and there are other plug-ins to accomplish similar functionality. If it's an FAQ style interface, then it may make sense to hide all the sections and show the sections when they click on the question/title, which can be accomplished with
$("SOMETHING").toggle()
in jQuery.根据您想要达到的结果,有多种选择。
将长页面分成几页是标准方法。
另一种方法是使用一些 JavaScript 显示/隐藏这些部分。这将使页面看起来更好(例如更短)。
另一种方法是通过某种 AJAX 加载内容,这是两者的交叉。您将拥有单独的页面,然后通过 javascript 加载内容。这具有两者的好处,因为您的 AJAX 加载的内容将是页面之间的良好过渡,但您可以以搜索引擎将转到实际页面的方式对其进行编码。
另一种选择(取决于您的内容)是当今的趋势,是具有某种滚动视差背景。这是一个 http://unfold.no/ 的示例
这些网站需要 CSS3/javascript/设计知识才能创造出漂亮的东西。
There are several options depending on the result that you want to achieve.
Separating a long page into several pages is your standard method.
Another method is to show/hide the sections with some javascript. This will make the page look nicer (e.g. less long).
Another method would be to load in the content via some AJAX, which is a cross between the two. You would have your separate pages, then load the content in through javascript. This has the benefit of both, in that your AJAX loaded content will be a nice transition between pages, but you can code it in a way that search engines will go to the actual page.
Another option (depending on your content), which is a trend these days, is to have some sort of scrolling Parallax background. this is an example of one http://unfold.no/
These websites require knowledge of CSS3/javascript/design in order to create something nice.
像这样的东西应该可以在 jQuery 中工作。我不知道有什么方法可以用纯 CSS 获得相同的结果。
Something like this should work in jQuery. I don't know of a way to get the same result with pure CSS.