html - 如何为所有 HTML 页面使用我的 CSS 中的通用 header ?

标签 html css

<分区>

我有这个标题的 css:

.panelSuperior{
    position: relative;
    top: 0;
    left: 0;

    width: 100%;
    height: 250px;
    background-repeat: no-repeat;
}

.logo{
    position: absolute;
    top: 25px;
    left: 35%;

    width: 350px;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

这是我的 html:

<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>index.html</title>
<link rel="stylesheet" href="index.css">

</head>

<body>
    <div class="panelSuperior">
        <img alt="fondoPrincipal" src="fondoPrincipal.jpg" class="panelSuperior"/>
    </div>

    <div class="logo">
        <img alt="logoFlorida" src="logoFlorida.png" class="logo"/>
    </div>
    <br>
</body>
</html>

我想为我拥有的所有 html 页面使用该 header 。我试着在网上做一些研究,但所有的答案都是用 php,而我必须用 html 来做。有什么办法吗?

最佳答案

服务器端语言出现之前的老派东西。

选项 1

  • 将页眉复制/粘贴到您所有的 html 页面上

选项 2

  • 使用 Javascript 来“包含”那个 div。下面是使用 jQuery 的示例,但您可以使用 Vanilla Javascript 轻松完成

    $('body').prepend('你的头部代码');

选项 3

  • 为页眉使用 iFrame

关于html - 如何为所有 HTML 页面使用我的 CSS 中的通用 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56048568/

上一篇:html - 如何定位 YouTube iframe?

下一篇:css - 显示和修改 JSON 数据(显示在表格中)使用 React JS

相关文章:

html - 媒体查询 : smartphone-landscape is executing for iPad

javascript - document.location.href 重置全局变量

html - 相对路径URL问题

html - 所有移动设备上的右栏底部

javascript - 进度条描边颜色

html - 在响应式滚动表中保留标题修复

html - 通过 HTML5 客户端连接到 Azure 远程应用程序

jquery - 仅在 Chrome 中水平滑动时出现延迟

javascript - 在没有 jquery 的较小 div 中滚动溢出 div 的可见部分

javascript - Shopify 产品页面以隐藏变体图像