我是否必须使用 Bootstrap 在每个页面上复制导航栏代码? [英] Do I have to duplicate the navbar code on every page with Bootstrap?

查看:31
本文介绍了我是否必须使用 Bootstrap 在每个页面上复制导航栏代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用具有多个页面的引导程序制作网站.我的方法是创建多个 html 文件,例如Index.html、Products.html、Contact.html.

I'm currently making a site with bootstrap that has multiple pages. My approach was to create multiple html files, e.g. Index.html, Products.html, Contact.html.

现在,我是否必须在每个文件中复制导航栏的代码?这看起来相当麻烦,因为当我想在导航栏中更改某些内容时,我必须在每个文件中都进行更改.

Now, do I have to duplicate the code for my navbar in every of those files? This seems rather cumbersome, as when I want to change something in the navbar, I have to go change it in every single file.

(当然,代码不会完全重复,例如每个 html 页面上的活动类都不同,但 99% 是通用代码)

(Of course the code won't be an exact duplicate, as e.g. the active class is different on each html page, but like 99% is common code)

我当然知道我可以使用像 Joomla 这样的 CMS 来为我处理这个问题.但是,如果我不想迈出这一步,Bootstrap 可以吗?或者这不是 Bootstrap 的用途?奇怪的是,通过我的查询,我无法在该主题上获得任何谷歌点击.也许我错过了什么.

I of course know that I could use a CMS like Joomla that would handle this for me. But if I don't want to take that step, is it possible with Bootstrap? Or is that not what Bootstrap is for? Curiously, I couldn't get any google hit on that topic with my queries. Maybe I'm missing something.

推荐答案

我觉得这个问题的最佳答案是不,仅使用 Bootstrap 是不可能的",更重要的是,不,这不是什么Bootstrap 是为了".

I feel like the best answer to this question is "No, it's not really possible with only Bootstrap", and even more important, "No, it's not what Bootstrap is for".

Bootstrap 是一个用于开发网站图形和布局的框架,它不包含任何带有菜单的多页边的逻辑"以及在它们之间切换等等.(它确实包含一些逻辑,但它是为了响应不同的设备尺寸,这是在 CSS 中完成的).

Bootstrap is a framework for developing the graphics and layout of websites, and it doesn't contain any "logic" for multi-page sides with menus and switching between them and stuff like that. (It does contain some logic, but it's for responsiveness w.r.t. different device sizes, and that's done in CSS).

您真正想要的是像 Rails 或 Django 这样的 Web 框架,或 CMS,然后在其上使用 Bootstrap 进行设计和布局.或者,任何其他建议的 PHP 或 Javascript 答案,以获得更自制"的解决方案.

What you really want is a web framework like Rails or Django, or a CMS, and then use Bootstrap on top of that for the design and layout. Or, any of the other suggested answers in PHP or Javascript for a more "home-built" solution.

这篇关于我是否必须使用 Bootstrap 在每个页面上复制导航栏代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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