当创建新页面时,不考虑css [英] When new page is created, the css is not taken into account

查看:127
本文介绍了当创建新页面时,不考虑css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以自动创建一个新的网页与用户输入,但只有一个问题:css不工作。我知道如何附加一个CSS文件到一个HTML文件,但这一次,它只是不工作。



$ b

HTML

 

code><!DOCTYPE html>
< html lang =en>
< head>
< meta charset =utf-8/>
< title>< / title>
< link rel =stylesheettype =text / csshref =/ stylesheet.css>
< / head>
< body>
< - 网页内容 - >
< / body>
< / html>

所以,这是与它相关的HTML,以及CSS连接到HTML从字面上复制和粘贴从工作的另一个页面。我也确保不使用div,但使用类,因为它可能会导致问题。还有一个问题,当我尝试使用PHP添加标题和页脚文件到我的文档,有一个错误如下:警告:include(header.php)[function.include]:无法打开流:在/home/content/55/10690555/html/words/tower.php在第2行没有这样的文件或目录
我不知道为什么这是发生在这个页面,但没有任何其他的,所以任何帮助将非常感激。顺便说一下,有错误的文件是使用PHP创建新文档的模板,如果这有帮助。

解决方案

如果你使用php来包含CSS文件,你可能使用 include(header.php)。这可能不工作有时。



要获取根位置,请包含 $ root = realpath($ _ SERVER ['DOCUMENT_ROOT']); ,并在 include()函数中的文件名之前附加 $ root / p>

I am able to automatically make a new webpage with user input, but there is only one problem: the css doesn't work on this. I know how to attach a css file to a HTML file, but this time, it just doesn't work. To help you visualize this, here is the code I have so far.

HTML

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <link rel="stylesheet" type="text/css" href="/stylesheet.css">
    </head>
<body>
<--content for webpage here-->
       </body>
</html>

So, that is the relevant HTML to go with it, and the connection of the CSS to the HTML was literally copy and pasted from another page that worked. I also made sure not to use divs, but to use classes because it could've caused problems. There is also a problem, that when I try to add the header and footer file to my document using php, there is an error as follows: Warning: include(header.php) [function.include]: failed to open stream: No such file or directory in /home/content/55/10690555/html/words/tower.php on line 2 I have no idea as to why this is happening on this page but not any other ones, so any help would be greatly appreciated. By the way, the file with the errors, is the template for creating a new document using PHP if that helps at all.

解决方案

If you are using php to include the CSS files, you might probably be using include(header.php). This might not work sometimes. Use the absolute path instead.

To get the root location, include $root = realpath($_SERVER['DOCUMENT_ROOT']); at the top and append$root variable before the filename inside the include() function.

这篇关于当创建新页面时,不考虑css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆