" That's it."/> " That's it.">

Home  >  Article  >  PHP Framework  >  What should I do if thinkphp’s css reference does not come in?

What should I do if thinkphp’s css reference does not come in?

藏色散人
藏色散人Original
2021-12-27 11:54:002100browse

Solutions for thinkphp css references not coming in: 1. Check the storage location of js, css, img and other files; 2. Modify the way to reference css to "".

What should I do if thinkphp’s css reference does not come in?

The operating environment of this article: Windows 7 system, thinkphp v5.1 version, Dell G3 computer.

What should I do if the css reference of thinkphp does not come in?

thinkphp5 references external css and the js path is indeed correct. Why is there no response?

After working on it all morning, I found out the reason and share it with you. Let me explain it with a css example:
1. We As you know, the js, css, img and other files we write are placed in public/static.
Here is the specific location map:
What should I do if thinkphp’s css reference does not come in?
The three codes are as shown in the figure: 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

<?php namespace app\index\controller;

class Index
{
    public function index()
    {
    return view(&#39;index&#39;,[
        &#39;name&#39;=>'帅哥',
    ]);
    }
}

css

p{
    background-color: #000088;
}

is like this, I use the most common link, through the picture above, Everyone knows that there is no problem.

Then we visit the local browser, it looks like thisWhat should I do if thinkphp’s css reference does not come in?
There is no blue background, indicating that the link is not used
Why? The path is not used correctly Ah?
Then I found out through research that first of all, the integration software I use is laragon. This is not the point. I will post the root directory I set to
What should I do if thinkphp’s css reference does not come in?
which is public, and then my link. It is , it should be changed to , so it is successful.
What should I do if thinkphp’s css reference does not come in?
As shown in the picture, there is a background color.
To sum up, the css is ineffective because of the wrong judgment of the root directory. I hope my explanation will be helpful to everyone.

Recommended learning: "The latest 10 thinkphp video tutorials"

The above is the detailed content of What should I do if thinkphp’s css reference does not come in?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is thinkphp routingNext article:what is thinkphp routing