" That's it."/> " That's it.">
search
HomePHP FrameworkThinkPHPWhat should I do if thinkphp's css reference does not come in?

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 thinkphps 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 thinkphps 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 thinkphps 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 thinkphps 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
宝塔部署thinkphp5报错怎么办宝塔部署thinkphp5报错怎么办Dec 19, 2022 am 11:04 AM

宝塔部署thinkphp5报错的解决办法:1、打开宝塔服务器,安装php pathinfo扩展并启用;2、配置“.access”文件,内容为“RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]”;3、在网站管理里面,启用thinkphp的伪静态即可。

thinkphp5 post得不到值怎么办thinkphp5 post得不到值怎么办Dec 06, 2022 am 09:29 AM

thinkphp5 post得不到值是因为TP5是通过strpos函数在Header的content-type值中查找app/json字符串的,其解决办法就是设置Header的content-type值为app/json即可。

thinkphp5怎么获取请求过来的网址thinkphp5怎么获取请求过来的网址Dec 20, 2022 am 09:48 AM

thinkphp5获取请求网址的方法:1、使用“\think\Request”类的“$request = Request::instance();”方法获取当前的url信息;2、通过自带的助手函数“$request->url()”获取包含域名的完整URL地址。

thinkphp5 url重写不行怎么办thinkphp5 url重写不行怎么办Dec 12, 2022 am 09:31 AM

thinkphp5 url重写不行的解决办法:1、查看httpd.conf配置文件中是否加载了mod_rewrite.so模块;2、将AllowOverride None中的None改为All;3、修改Apache配置文件.htaccess为“RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]”保存即可。

怎么去除thinkphp5标题栏icon怎么去除thinkphp5标题栏iconDec 20, 2022 am 09:24 AM

去除thinkphp5标题栏icon的方法:1、找到thinkphp5框架public下的favicon.ico文件;2、删除该文件或者选择另一张图片命名改为favicon.ico,并替换原favicon.ico文件即可。

thinkphp5提示控制器不存在怎么办thinkphp5提示控制器不存在怎么办Dec 06, 2022 am 10:43 AM

thinkphp5提示控制器不存在的解决办法:1、检查对应的控制器里面的命名空间是否写对,修改为正确的命名空间;2、打开相应的tp文件,修改类名即可。

ThinkPHP5怎么查询昨天的数据ThinkPHP5怎么查询昨天的数据Dec 05, 2022 am 09:20 AM

ThinkPHP5查询昨天数据的方法:1、打开ThinkPHP5相关文件;2、通过表达式“db('table')->whereTime('c_time', 'yesterday')->select();”查询昨天的数据即可。

thinkphp5报错提示怎么设置thinkphp5报错提示怎么设置Dec 07, 2022 am 10:31 AM

thinkphp5设置报错提示的方法:1、进入项目根目录下的public文件夹,打开index.php入口文件;2、查看调试模式开关的注释;3、将“APP_DEBUG”常量的值调整为true即可展示错误信息提示。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),