【问题标题】:How to use class in anchor tag and img tag如何在锚标签和img标签中使用类
【发布时间】:2016-12-11 22:01:34
【问题描述】:
 <a href="images/xyz.jpg" class="swipebox"><img src="images/abc.jpg" class="img-style row2"></a>.  

我必须在 cakephp3 中使用上面的代码。我已经通过 html helper 进行了尝试,但我的代码存在一些语法错误。

这是我的代码,

<?php echo $this->Html->link('".$this->Html->image('abc.jpg', ['class' => 'img-style row2'])."', $this->Html->image('xyz.jpg', ['class' => 'swipebox'])); ?>

请在这方面帮助任何人。

【问题讨论】:

    标签: cakephp cakephp-2.0 cakephp-3.0


    【解决方案1】:

    使用图片方法进入链接方法然后使用'escape' =&gt; false,见示例

    echo $this->Html->link(
                  $this->Html->image('img.jpg',['class'=>'img-class','alt'   => 'img',]),
                  ['controller'=>'', 'action'=>''],
                  ['escape' => false,'class'=>'link-class'] 
    );
    

    【讨论】:

    • 感谢您的帮助
    最近更新 更多