简体   繁体   English

HTML(PHP)链接CSS文件

[英]HTML (PHP) linking CSS files

I have maybe ten .php files that make up the main pages of my website and 20 .css files all in all. 我大概有十个.php文件构成了我网站的主页,总共有20个.css文件。 I noticed that when I made a submit button in one file, it adopted the attributes of a .css file that I had not linked through the normal html way. 我注意到,当我在一个文件中创建一个提交按钮时,它采用了一个.css文件的属性,而我没有通过常规的html方式进行链接。

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

However, I have referenced other .php files like this: 但是,我引用了其他.php文件,如下所示:

include('config.php');

And then in config I referenced many other files in some kind of tangled web. 然后在配置中,我引用了一些杂乱的web中的许多其他文件。

Does that mean that css is passed on through the PHP include method - and that in multiple layers? 这是否意味着css是通过PHP include方法传递的,并且是多层传递的? eg if I referenced a file in config.php that didn't directly reference a css file, but instead another php file which maybe DID directly reference css. 例如,如果我在config.php中引用了一个文件,该文件没有直接引用css文件,而是另一个php文件,也许DID直接引用了css。

I have to apologize if this is a slightly confused question, it's just my mind cannot comprehend this... CSSCeption... 如果这是一个有点困惑的问题,我必须道歉,只是我的想法无法理解这个... CSSCeption ...

Consider this... If you go to your site and right click the page and click view source. 考虑一下...如果您转到自己的站点并右键单击该页面,然后单击查看源。 You will see your entire document, including any items that might be included. 您将看到整个文档,包括可能包含的所有项目。

Think of it in this way. 以这种方式考虑它。 An include, is a sort of way of saying, at this position in the document, there should be other things. 包含是一种表达方式,在文档中的此位置应有其他内容。 It looks for the file you include and takes it's contents, whatever that is, and sticks those contents where the include is, it will do this with every include until it finally reaches the end of the document. 它会查找您包含的文件,并获取其内容(无论包含什么内容),并将那些内容粘贴到包含内容的位置,它将对每个包含内容执行此操作,直到最终到达文档末尾。

In this way, it brings in HTML that has your CSS files linked, and then it reads the HTML that it just brought in, and it applies those CSS files styles to the entirety of the document after all of the HTML has been loaded. 通过这种方式,它引入了链接了CSS文件的HTML,然后读取了刚刚引入的HTML,并且在所有HTML加载完毕后,将这些CSS文件样式应用于整个文档。

First of all you must know that CSS doesn't "know" what php means, CSS defines HOW HTML elements are to be displayed . 首先,您必须知道CSS不“知道” php含义, CSS定义了如何显示HTML元素 So it will take place after the web server converts all your php code into html . 因此,它将在web server将所有php代码转换为html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM