简体   繁体   English

如何设置一个包含<header></header>并且可以链接到所有页面?

[英]How do I set up one page that containers the <header></header> and can be linked to all pages?

I want to create one page to contain the <header></header> for all my pages.我想创建一个页面来包含我所有页面的<header></header> Meaning I can link all my stylesheets without having to go page by page.这意味着我可以链接我所有的样式表,而不必逐页链接 go。

Any ideas?有任何想法吗? I'm using Visual Studios.我正在使用 Visual Studio。

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge, IE=11">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="Drool Design Studio">
    <meta name="apple-mobile-web-app-title" content="Drool Design Studios">

    <title>Drool Design Studio</title>

    <!--FAVICON-->
    <link rel="icon" type="image/png" href="/images/logo/favicon.png" />

    <!--STYLE SHEETS-->
    <link href="style/global.min.css" rel="stylesheet" />
    <link href="style/header.min.css" rel="stylesheet" />
    <link href="style/sections.min.css" rel="stylesheet" />
    <link href="style/footer.min.css" rel="stylesheet" />
    <link href="style/buttons.min.css" rel="stylesheet" />
    <link href="style/scroll.min.css" rel="stylesheet" />
    <link href="style/reviews.min.css" rel="stylesheet" />

    <!--JS-->
    <script src="https://kit.fontawesome.com/662c8a0fc8.js" crossorigin="anonymous"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

</head>

Usually you use PHP for this.通常为此您使用 PHP。 Make a file 'header.php' and include that in every other PHP page with: include 'header.php';制作一个文件'header.php'并将其包含在每个其他PHP页面中: include 'header.php';

But PHP works on the server, so you need to have a server space somewhere to run it on.但是 PHP 在服务器上工作,所以你需要在某个地方有一个服务器空间来运行它。 You can test a server at home on your own computer with Apache though: https://www.apachefriends.org/index.html您可以使用 Apache 在您自己的计算机上在家中测试服务器: https://www.apachefriends.org/index.html

I use Flask.我使用 Flask。 Flask has Templating using Jinja2. Flask 具有使用 Jinja2 的模板。 Here's what the server-side[flask] and html template side[jinja2-html] looks like:下面是服务器端 [flask] 和 html 模板端 [jinja2-html] 的样子:

** [yourflaskappname]/crud.py** ** [yourflaskappname]/crud.py**

from flask import Flask
crudSEapi = Blueprint('crudSEapi', __name__)

app = Flask(__name__)

@crudSEapi.route("/issue_tracker/", methods=['GET', 'POST'])
def issue_tracker():

    

    flows, issue_next_page = get_model().Crud.factory('issue').issues_bf()

return render_template('issue_tracker/BF_FE_view1_v2.html', my_string="Wheeeee!", my_list=[0,1,2,3,4,5])

So below you will see how you can use jinja with flask.因此,下面您将看到如何将 jinja 与 flask 一起使用。 Note the {{ }}.注意 {{ }}。 you can call values into {{ }} from the server, and dynamically places the data into the HTML template.您可以从服务器调用值到 {{ }},并动态地将数据放入 HTML 模板。 templates are so amazing and powerful.模板是如此惊人和强大。 flask is easy to learn. flask 易于学习。 Make sure to learn JS too!一定要学习JS!

** [yourflaskappname]/templates/issue_tracker/BF_FE_view1_v2.html** ** [yourflaskappname]/templates/issue_tracker/BF_FE_view1_v2.html**

<HTML>

<HEAD>

<TITLE>Your Title Here</TITLE>

</HEAD>

<BODY BGCOLOR="FFFFFF">

<HR>



<p>My string: {{my_string}}</p>
<p>Value from the list: {{my_list[3]}}</p>
<p>Loop through the list:</p>
  <ul>
    {% for n in my_list %}
    <li>{{n}}</li>
    {% endfor %}

<HR>

</BODY>

</HTML>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在其余所有页面中具有第一页的相同页眉 - How can i have same header of first page in rest of all the pages 如何为网页上的链接设置Accept Header? - How can I set the Accept Header for a link on a web page? 例如,如何在不手动更改所有页面的情况下,编辑一个HTML文件的标题并使它对所有其他页面都相同? - How to edit, for example, the header of one HTML file and make it do the same to all other pages, without changing all the pages manually? PHP标头包含页面未在所有页面上显示 - PHP header include page not displaying on all pages 不包括第一页的所有页眉 - RotativaPDF - All pages with header excluding first page - RotativaPDF 如何为我的所有jQuery Mobile页面调用页眉和页脚? - How can I call a header and footer for all of my jQuery Mobile pages? 如何加载标题,更改标题,然后重定向到包含更新标题的页面? - How can I load a header, change it, then redirect to a page with the updated header? 如何获得页面中间的标题? - How do I get the header in the middle of the page? 如何设置带有水平滚动页的固定标题? - How to set up a fixed header with a horizontal scrolling page? 在打印时,如何在 CSS 页面上重复页眉和页脚横幅? - On print, how do I repeat header and footer banners on pages in CSS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM