如何实现可重用的HTML导航菜单? [英] How to implement reuseable HTML Navigation menus?

查看:942
本文介绍了如何实现可重用的HTML导航菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这个主题一直出现,但我似乎不能提供一个简明的答案。我有一个垂直的菜单栏,我想在我们的网站(> 20)中重复使用该网站。
$
菜单栏编码为html(UL,LI,A),使用Div标签和CSS实现所需的效果。

I'm sure this topic comes up all the time, but I can't seem to fine a concise answer. I've got a vertical menu bar that I want to reuse in our web pages (>20) for the site.
The Menu bar is coded in html (UL, LI, A), uses Div tags and CSS to achieve the desired effects.

我们想找到最简单的方法来重用所有网页中的菜单栏,同时能够根据需要维护和缩放,所以我们不必每次添加页面时都修改所有页面。我们宁愿避免编码方法,如果可能,意味着我们可以只有一个主文件,我们根据需要编辑。正在我们使用CSS和DIV的我不hink框架是答案。有什么想法吗?

We want to find the simplest approach to reusing the menu bar in all web pages while being able to maintain and scale as needed, so we don't have to modify all pages every time we add a page. We'd rather avoid a coding approach if possible, meaning we could live with just one master file that we edit as needed. Sine we're using CSS and DIV's I don't hink frames are the answer. Any thoughts?

推荐答案

如果您不想使用编程语言,服务器端包括的方法。

Server side includes are the way to go if you don't want to use a programming language.

它们采用以下形式:

<!--#include virtual="menu.html" -->

,并将插入到您在HTML中放置该标记的页面。它需要服务器端解析,因此您的Web服务器必须包含启用的服务器端。您可以尝试,如果它不工作,请与您的服务器主机,看看是否可以让他们启用。如果是Apache,则通过.htaccess文件有启用它们的方法

and will be inserted in the page wherever you put that tag in your HTML. It requires server side parsing, so your web server must have server side includes enabled. You can try it out, and if it doesn't work, contact your server host to see if you can get them enabled. If it's Apache, there's a method of enabling them via .htaccess files as well.

这篇关于如何实现可重用的HTML导航菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆