<分区>
<分区>
我有这个标题的 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
选项 2
使用 Javascript 来“包含”那个 div。下面是使用 jQuery 的示例,但您可以使用 Vanilla Javascript 轻松完成
$('body').prepend('你的头部代码');
选项 3
关于html - 如何为所有 HTML 页面使用我的 CSS 中的通用 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56048568/