加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

CakePHP – 包含基于特定页面的CSS?

发布时间:2020-12-13 18:25:17 所属栏目:PHP教程 来源:网络整理
导读:我想要包含一个应该应用于主页的特定css文件,以及整个网站中的6-7个其他页面. 我知道我可以通过PHP,获取URL,找到什么页面,链接css等等来做到这一点,但我想知道是否有一个光滑的方式(或任何更好的方式)使用CakePHP包含正确的CSS文件(S). 我意识到我可以从特定
我想要包含一个应该应用于主页的特定css文件,以及整个网站中的6-7个其他页面.

我知道我可以通过PHP,获取URL,找到什么页面,链接css等等来做到这一点,但我想知道是否有一个光滑的方式(或任何更好的方式)使用CakePHP包含正确的CSS文件(S).

我意识到我可以从特定的视图链接CSS文件,但是 – 然后它们不会在< head>中.有没有办法从视图中链接并将其显示在头部?

我希望我的问题有意义,并且非常感谢任何帮助.

I realize I can link the CSS file from
the specific views,but – then they
wouldn’t be in the <head>. Is there a
way to link from a view and have it
show up in the head?

是的,他们会在头脑中.见HTML Helper documentation:

If key ‘inline’ is set to false in
$options parameter,the link tags are
added to the $scripts_for_layout
variable which you can print inside
the head tag of the document.

那么,你的视图中的这个片段……

$this->Html->css('my-css',null,array('inline' => false));

…将添加正确的< link>元素到你的< head>.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读