下面是具體位置圖:
三個代碼如圖所示: index.html index.php index.css
html
<!doctype html><html><head> <meta charset=\”UTF-8\”> <meta name=\”viewport\” content=\”width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\”> <meta http-equiv=\”X-UA-Compatible\” content=\”ie=edge\”> <title>Document</title> <style> p{ color: red; } </style> <link rel=\”stylesheet\” href=\”public/static/index.css\”></head><body><p>{$name}歡迎你</p></body></html>
php
<?phpnamespace app\\\\index\\\\controller;class Index{ public function index() { return view(\’index\’,[ \’name\’=>\’帥哥\’, ]); }}
css
p{ background-color: #000088;}
是這樣的,我使用的是最普通的鏈接 ,通過上圖,大家知道是沒問題的。
然后我們訪問一下本地瀏覽器,是這樣的 沒有藍色的背景,說明link沒有用 為什么呢?路徑?jīng)]用錯??? 然后研究發(fā)現(xiàn),首先說明一下,我用的集成軟件是laragon,這不是重點,我發(fā)下我設置其根目錄是 是public,然后我的鏈接是<link rel=“stylesheet’ href=”/public/static/index.css\”>,應該改為<link rel=“stylesheet’ href=”/static/index.css\”>,所以成功了 如圖有了背景顏色。 綜上所述,是因為根目錄的判斷錯誤導致的css沒效果,希望我的說明對大家有所幫助。
推薦學習:《最新的10個thinkphp視頻教程》
更多關于云服務器,域名注冊,虛擬主機的問題,請訪問西部數(shù)碼官網(wǎng):m.ps-sw.cn