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

php – 如何在Zend Framework中编写内部样式表?

发布时间:2020-12-13 22:11:58 所属栏目:PHP教程 来源:网络整理
导读:我想在Zend Framework中为一个视图编写一个内部样式表 head style type="text/css" media="all" body{ background: #FFFFFF; } /style/head 我知道我可以使用$this- view- headLink() – appendStylesheet(‘style.css’);写一个外部样式表. 但是我找不到编
我想在Zend Framework中为一个视图编写一个内部样式表

<head>
   <style type="text/css" media="all"> 
      body{ background: #FFFFFF; }
   </style>
</head>

我知道我可以使用$this-> view-> headLink() – > appendStylesheet(‘style.css’);写一个外部样式表.

但是我找不到编写内部样式表的方法.有任何想法吗?

解决方法

您正在寻找的是HeadStyle视图助手.它的手册文档可以在 here找到.

HeadStyle助手的API与所有Head *视图助手一致,并且可以这样工作(以下假设您在视图中):

// Putting styles in order: 
// These methods assume the a string argument containing the style rules.

// place at a particular offset:
$this->headStyle()->offsetSetStyle(100,$customStyles);

// place at end:
$this->headStyle()->appendStyle($finalStyles);

// place at beginning
$this->headStyle()->prependStyle($firstStyles);

// Or capturing a block of styles

<?php $this->headStyle()->captureStart() ?>
body {
    background-color: <?php echo $this->bgColor ?>;
}
<?php $this->headStyle()->captureEnd() ?>

请注意,您不包含< style>任何此输入中的标记.这是由助手本身产生的.
然后,在您的布局中,只需回显您希望其输出的帮助器:

<head>
    <?php echo $this->headLink() ?>
    <?php echo $this->headStyle() ?>
</head>

(编辑:李大同)

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

    推荐文章
      热点阅读