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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 如何在Zend Framework中编写内部样式表?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在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>

脚本宝典总结

以上是脚本宝典为你收集整理的php – 如何在Zend Framework中编写内部样式表?全部内容,希望文章能够帮你解决php – 如何在Zend Framework中编写内部样式表?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。