如何使可重用的HTML导航菜单? [英] How To Make Reuseable HTML Navigation Menus?

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

问题描述

我确定这个话题总是会出现,

但是我似乎无法给出一个简洁的答案。

I'm sure this topic comes up all the time,
But I can't seem to fine a concise answer.

我有我想在网页中重复使用的垂直菜单栏(> 20)。
菜单栏用HTML编码,并使用以下用途: UL,LI,A < Div> 标签和CSS。我们需要这样做:

I've got a vertical menu bar that I want to reuse in webpages (>20). The Menu Bar is coded in HTML and uses uses: UL, LI, A, <Div> tags, and CSS. We need this:


  1. 可重复使用

  2. 可维护

  3. 可扩展

因此,我们不必在每次添加页面时都修改所有页面。

So we don't have to modify all pages every time we add a page.

我们宁愿避免使用编码方法(如果可能)。我们可以只保留一个需要根据需要编辑的主文件。由于我们使用的是 CSS < div> s,因此我认为框架不适合我们。我们该怎么办?

We'd rather avoid a coding approach if possible. We could live with just one master file that we edit as needed. Since we're using CSS and <div>s, I don't think frames scale for us. What can we do?

推荐答案

如果不想使用编程语言,则可以使用服务器端的方法。

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天全站免登陆