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

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

问题描述

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



现在,我是否必须在每个文件中复制我的导航栏的代码?这似乎相当麻烦,因为当我想改变导航栏中的某些内容时,我必须在每一个文件中更改它。



(当然代码不会是一个确切的重复,因为例如每个html页面上的活动类是不同的,但像99%是常见的代码)

我当然知道我可以使用CMS像Joomla那样会为我处理这个问题。但是如果我不想采取这一步骤,Bootstrap有可能吗?或者这不是Bootstrap的目的?
奇怪的是,我无法通过我的查询获得有关该主题的任何谷歌搜索。也许我错过了什么。

解决方案

我觉得这个问题的最佳答案是不,只有Bootstrap,甚至更重要的是,不,它不是Bootstrap的用途。

Bootstrap是开发网站图形和布局的框架,不包含带菜单的多页面的任何逻辑并在它们之间切换以及类似的东西。 (它确实包含了一些逻辑,但它是针对不同设备大小的响应能力,这是在CSS中完成的)。

你真正想要的是一个Web框架,比如Rails或者Django ,或CMS,然后在其上使用Bootstrap进行设计和布局。或者,其他PHP或Javascript中的其他建议答案可用于自制解决方案。


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.

(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)

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.

解决方案

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 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).

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