![](/img/trans.png)
[英]I am trying to get text from an HTML file, but I dont know how(googled but idk where to look)
[英]How can I use a CSS stylesheet that is up 2 directories from the file where I am trying to access it from?
我正在嘗試使用一個CSS樣式表,該樣式表包含2個目錄並在另一個文件夾中:
--project
--css
--main.css
--views
--shop
--products.php
我需要從products.php轉到main.css
據我所知,它應該是../../css/main.css
。 但它不起作用,將不勝感激,如果有幫助,我正在使用Chrome。
<link rel="stylesheet" type="text/css" href="../../css/main.css"/>
通常,您會將CSS和JS文件放置在應用程序的“ webroot”文件夾中。 這是您的最終用戶將能夠訪問的位置。 在此文件夾內,也將是您的PHP應用程序的入口。
因此,當我連接到www.example.com時,我將連接到其webroot文件夾:project / webroot / index.php,而其CSS可能位於:project / webroot / css / main.css
這樣做是出於安全性考慮,因為允許最終用戶遍歷您的源文件可能會發現漏洞(例如數據庫地址,用戶名和密碼!)。
當使文件可訪問時,請記住,它們需要從客戶端(而不只是服務器)可用!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.