Laravel在php页面上显示css效果

I tried a lot before asking this question here.

I am working on an android project called 5.2 that has a folder called CSS under public folder which contains css.css file. So the path of casacding style sheet file is :

5.2\public\CSS\css.css.

And I have a folder called Gordon which contains index.php.

the path is 5.2esources\views\Gordon\index.php

My problem css effects is not show.

index.php file.

     <html>
     <head>

     <title>
     </title>
     </head>
     <body>
     <?php

    {{ echo '<link href="{{ asset(CSS/css.css) }}" rel="stylesheet">'; 
    echo '<div class="one"> '; 
    echo ' Hello CSS  ';  
    echo '</div>' ;  }}
     ?>
    </body>
    </html>

css.css file

.one
{
color:red;
font-type:bold;
}

1个回答

Off the top of my head...

Rename file index.blade.php

To use blade and rewrite the code as:

<html>

<head>

  <title>
  </title>
</head>

 <body>

<link href="{{ asset('CSS/css.css') }}" rel="stylesheet">  
<div class="one">
Hello CSS
 </div> 
 </body>

</html>

You don't need the PHP tags because blade doesn't require them and blade syntax doesn't use echo if I remember correctly.

doujia5863
doujia5863 你可以,但我很确定你无法访问资产('CSS / css.css')
接近 3 年之前 回复
doufendi9063
doufendi9063 我在这里问我不能使用.php扩展并对代码进行一些更改?
接近 3 年之前 回复
duanchao9559
duanchao9559 我编辑@Chris快乐答案应该是<link href =“{{asset('CSS / css.css')}}”rel =“stylesheet”>
接近 3 年之前 回复
duanshan5259
duanshan5259 是的,因为{{}}内的内容是php。
接近 3 年之前 回复
dop83362
dop83362 我在2ea5a3850a11674191190e60310fe68c4c34b334.php中得到此错误ErrorException第11行:使用未定义的常量CSS - 假设'CSS'(查看:D:\ xampp \ htdocs \ 5.2 esources \ views \ Gordon \ index.blade.php)
接近 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐