gpt4 book ai didi

php - 内联 css 工作但外部和内部 css 在 index.php 中不起作用

转载 作者:行者123 更新时间:2023-11-28 12:48:22 26 4
gpt4 key购买 nike

正如问题所暗示的那样,我有一个包含 html 的 index.php 文件,当我尝试使用外部或内部 css 对其进行样式设置时,它不起作用。但是内联 css 有效。顺便说一下,我在 win7 上使用 xampp 来测试网站。文件结构如下所示 c:/xampp/htdocs/test/index.php

相关html:

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width>

<!--<link rel="stylesheet" type="text/css" href="style.css">-->
<!--This css file contains the css shown below as internal css-->

<style>
body{
background-color: blue;
color: white;
}
.header{
color: white;
}
</style>

<?php
function somefuntion(){
/*I will be adding this function later once the html skeleton
is done.
This function will be calculating some numbers based on the
current date and echoing it.*/
}
?>
</head>

<body>
<section class="header">
<p>Spring</p>
</section>
<section class="body">
<p>Hello world</p>
</section>
</body>
</html>

有人能解释一下为什么内部 CSS 不起作用吗?

hRdCoder找到的解决方法:meta标签的content属性中缺少"标记。

最佳答案

<link rel="stylesheet" type="text/css" href="style.css"></link>

唯一需要检查的是您是否添加了结束标记,以及 style.css 文件是否与您的 index.php 位于同一目录中。

编辑:

我刚刚注意到您在内容属性中缺少最后一组引号 (")。这会影响页面的其余部分吗?

关于php - 内联 css 工作但外部和内部 css 在 index.php 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24582164/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com