html - 尝试从静态 HTML 制作 WP 主题;CSS 未链接到 HTML 并且无法确定原因
问题描述
我正在尝试用静态 HTML 页面制作 WP 主题,以帮助我自愿参与的这个非营利组织。编码不是我的强项,所以我很挣扎。为了了解如何做到这一点,我观看了这个视频:https ://www.youtube.com/watch?time_continue=267&v=CZRgvAtwpxw&feature=emb_logo
简单总结一下,我将 HTML 分成页眉、索引和页脚部分,每个部分都保存为 header.php 等。
在编写代码时,HTML 加载时没有样式。我怀疑问题出在标题中,所以我将其粘贴在这里:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>A2Empowerment.org</title>
<link href="style.css" rel="stylesheet" type="text/css">
<div id="Layer1">
<p align="center"><a href="index.shtml"><img src="a2e_banner.png" alt="banner" width="650" height="145" border="0" /></a></p>
</div>
</head>```
**The index page is as follows:**
```<?php get_header(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<!--#include virtual="title.html"-->
<div id="Layer1">
<p align="center"><a href="index.shtml"><img src="a2e_banner.png" alt="banner" width="650" height="145" border="0" /></a></p>
</div>...```
**The CSS opens as follows:**
```/*
Theme Name: Man Ching's Theme.
Theme URI: www.a2empowerment.org
Description: Based on the original static HTML and CSS
Version: 1.0
Author: Dan Araujo
Author URI: none
*/
#Layer1{position:relative;
top:0%;
width: 100%;
z-index:1;
} ```
Any help on this issue would be fantastic. Everything is saved in the same folder. Thanks!
解决方案
首先,你不应该div
在你的head
. 它应该只在你的身体里。而且你不应该html
在关闭head
.
您必须检查 CSS 是否位于与当前 HTML 文件相同的文件夹(路径)上并正确加载。
1) 打开浏览器的开发工具(按 F12 或 CTRL+Shift+I)并查看“元素”选项卡。检查代码的“head”部分并单击指向 CSS 文件的链接(它将以 link href="style.css"... 开头) - 如果文件没有在您的浏览器上正确加载并且您可以看不到 CSS,那么你将不得不调整它的路径。
2)如果它已经在正确的路径上,并且您知道它应该可以工作,那么您的 .htaccess 可能会将所有请求(甚至是那些到 css 文件的请求)重定向到其他内容,并且需要对其进行调整。
这些是首先要检查的。在检查并回答这些问题后,我们可能会为您提供进一步的帮助。
推荐阅读
- php - 如何使用 RESTFul API 在 Laravel 中管理无状态?
- typescript - 如何在 Typescript 转译中使用导入和导出?
- php - 如何使用 codeigniter 3 和 jquery 1.12.4 修复我的函数中的错误
- python - 如何从当前字典返回具有列表值的新字典?
- jira-rest-api - 需要使用 Jira python 获取问题链接类型
- java - Android 中的并发
- python - 为什么Python排序将大写项目放在第一位?
- javascript - npm lint 上可观察到的“不推荐使用源”错误
- javascript - 获取数组内数组中的值
- angular - 如何在 ngFor 中做动态表达?