Universal header in HTML

牧云@^-^@ 提交于 2019-12-12 03:31:13

问题


I want to create a universal header (and footer) using HTML/CSS/Javascript so that if I update it to one page, it automatically updates on the rest. I also want to be able to choose which link is showing up with the active class on it. Also, I am using bootstrap. Here are some criteria I need to meet:

  • No PHP
  • No Server side (must work on github pages)

Thank you in advance,

Albert


回答1:


You can use jQuery to .load a HTML file:

HTML

<div id="header"></div>

jQuery

$('#header').load('static.html');

Alternatively, you could use iframe to load your static header. See this answer for more information regarding the available techniques.




回答2:


Maybe try Jekyll, this is a tool to generate static pages, also this is how the githup page handles your own personal page. You just follow the file structure and set the layout properties in your files, then you can use the universal layout (including header, footer etc.) in your page.

Here is a link to Jekyll.Jekyll



来源:https://stackoverflow.com/questions/42685939/universal-header-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!