简体   繁体   English

如何链接CSS文件以与WAMP服务器正常工作?

[英]How to link css files to work correctly with wamp server?

I have this line in the head of a php.page 我在php.page的头中有这行

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

LiveView in dw - shows everything formated well (css works) dw中的LiveView-显示一切格式正确(css正常工作)
f12 (using wamp) - also works well. f12(使用沼泽)-也很好用。
Now, I changed some line in header.css (for example cell padding) - then File - Save All 现在,我更改了header.css中的某些行(例如单元格填充)-然后更改了文件-全部保存
Live View still works - shows the changes correctly 实时显示仍然有效-正确显示更改
But f12 (wamp) does not show the changes. 但是f12(wamp)不显示更改。
If I move header.css file from css folder to the root folder (and change the link) - wamp works well 如果我将header.css文件从css文件夹移动到根文件夹(并更改链接)-wamp效果很好
But I want to have my css files in css folder, not in the root folder. 但是我想将css文件放在css文件夹中,而不是在根文件夹中。 What is the solution, please? 请问解决办法是什么?

Clear your browser cache. 清除浏览器缓存。 That should fix the issue. 那应该解决问题。 You can do it automatically if you use ctrl+F5 in your browser. 如果在浏览器中使用ctrl + F5,则可以自动执行此操作。

Find your web root path and append it to the css file 找到您的Web根路径并将其附加到CSS文件

Example. 例。

<link href="<?php echo $webroot?>/yourfolder/css/header.css" rel="stylesheet" type="text/css" />

You could use 你可以用

<link href="css/header.css<?php echo '?rnd_'.urlencode(time()).'='.urlencode(rand()); ?>" rel="stylesheet" type="text/css" />

For debugging purposes this is ideal, because it appends a random query string to the CSS-file-request in order not to be cached. 出于调试目的,这是理想的,因为它将随机查询字符串附加到CSS文件请求中,以便不被缓存。

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

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