2

Cakephp 2.1.3 中的图像路径有点问题。现在我必须使用:

<td background="../../img/login25.png" width="22" height="15"></td>

我需要为我的视图中的所有标签设置 webroot 的路径。如何在我的视图中更改路径以便我可以使用:

 <td background="login25.png" width="22" height="15"></td>

有人可以告诉我们在哪里以及如何做到这一点吗?我找了几个小时,但我只能找到 $this->Html 函数等的路径。谢谢

4

3 回答 3

3

Erk...我可以建议一种替代方法,并在样式表中使用 CSS 设置背景图像吗?然后路径将相对于样式表位置。

'background' 不是 td 元素的有效属性。

我什至不会问你用桌子做什么!;-)

于 2013-05-02T10:40:41.427 回答
0
use css code to call file in td with id or class.


<td class="myimage" width="22" height="15"></td>

use the css code bellow in .css file you are calling or create css file and save to app/webroot/css/ directory.

.myimage { 

  background: url("pathtoimgfolder/b_grijs_a.png");

 }
 For Example : I want to use image from app/webroot/img/a.png
 so I am using :

.myimage { 
   background: url("../img/a.png");
}

:) 快乐编码

于 2013-05-02T11:39:37.407 回答
0

找到了:

 <td background="<?php echo $this->webroot; ?>img/login25.png"  width="22" height="15"></td>
于 2013-05-02T13:22:54.253 回答