开发者

An image link won't work on codeigniter

Can anybody explain to me why this won't work on CodeIgniter?

.linkBack{
   background-image:url('/myBlog/CodeIgniter_1.7.2/pictures/arrow.gif');
 display:block;
 height:58px;
 width:105px;
 text-indent:-999px;
}  

<div class="linkBack"><?=anchor('myBlog', 'Back to Blog');?></div>

while this would work perfectly:

#linkBack {
 background-image:url(/myBlog/CodeIgniter_1.7.2/pictures/arrow.gif);
 position:fixed;
 left:10px;
        bottom:10px;
 display:block;开发者_运维知识库
 height:58px;
 text-indent:-9999px;
 width:100px;
}

<a href="/myBlog/CodeIgniter_1.7.2/index.php/myBlog"  id="linkBack">Back to Blog</a>

it is an image used as a link...


With the url helper loaded either via the contoller ($this->load->helper('url');) or via the helper array in /system/application/config/autoload.php; try:

anchor('myBlog',img(array('src'=>'/myBlog/CodeIgniter_1.7.2/pictures/arrow.gif','border'=>'0','alt'=>'My Blog')));


It may be something as simple as being more specific in your CSS selector (e.g. a#linkback).


The solution for getting img() to work is to make sure the HTML helper is loaded in autoload.php like this:

$autoload['helper'] = array('url','html');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜