CodeIgniter中加载css文件

<p><font size="4">CodeIgniter中加载css文件</font></p> <p><font size="4">1.用原始的html中的link标签 <br />2<strong>.用CodeIgniter内建的link_tag函数</strong></font></p> <p> <br /><font size="4"><strong>STEP1---载入ci的html helper <br /></strong>&#160;&#160; a.在对应的控制器中添加代码:<strong>$this-&gt;load-&gt;helper('html'); </strong> <br />&#160;&#160; b.在config/autoload.php文件中,<strong>修改$autoload['helper'] = array('html');</strong>这样CI会自动加载html助手。</font></p> <p> <br /><strong><font size="4">STEP2---使用</font></strong></p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:7b30ab2d-0e0d-435d-a7a0-e1c6dcc616d3" class="wlWriterEditableSmartContent"><pre class="brush: php; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 312px; height: 16px;" style=" width: 312px; height: 16px;overflow: auto;">echo link_tag('css/mystyles.css') </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>

<p><font size="4">它会输出</font></p>

<p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:8433f20d-e8e7-4866-9e38-7c9f3983a5b5" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 668px; height: 22px;" style=" width: 668px; height: 22px;overflow: auto;">&lt;link href=&quot;http://site.com/css/mystyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> </p>

<p><font size="4">复杂的使用: <br /></font>

<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ff9384c4-9865-46ac-bc14-48dc1cf05386" class="wlWriterEditableSmartContent"><pre class="brush: php; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 312px; height: 113px;" style=" width: 312px; height: 113px;overflow: auto;"> $link = array( 'href' =&gt; 'css/printer.css', 'rel' =&gt; 'stylesheet', 'type' =&gt; 'text/css', 'media' =&gt; 'print'); echo link_tag($link);</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>

<br /><font size="4">等效于</font></p>

<p><font size="4">&#160;</font>

<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:273d1530-4fe0-4cbf-8b17-3027d49c9908" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 781px; height: 38px;" style=" width: 781px; height: 38px;overflow: auto;">&lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> </p>

<p><font size="4"></font></p>

<p><font size="4"></font></p>

<p><font size="4"></font></p>

<p><font size="4"></font></p>

转载于:https://my.oschina.net/arunu/blog/104524

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值