【问题标题】:Link as image, in TD class created by CSS file链接为图像,在 CSS 文件创建的 TD 类中
【发布时间】:2014-08-10 04:38:14
【问题描述】:

我有 CakePHP 2.5.2。如何在此处修改 cake.generic.CSS 以将默认按钮更改为动作类表中 16x16px 的图像图标:

 <td class="actions">
            <?php echo $this->Html->link(__('Payment'), array( 
             'action' => 'add'); ?>
 </td>

如果不修改 CSS,我将无法做到这一点。我一直在谷歌上搜索,没有比这更好的了:

cake.generic.CSS

    #button123 {
       background-image: url('../img/image.png');
       display: block;
       margin: 0 auto;
       text-indent: -9999px;
       width: 16px;
       height: 16px;
   }

/查看/协议/index.php:

   <?php echo $this->Html->link(__('Task'), array( 
                        'controller' => 'tasks', 
                        'action' => 'add',
                         array( 'id' => 'button123')
                 ); ?>

有什么想法吗?

【问题讨论】:

    标签: php html css cakephp


    【解决方案1】:

    很难理解你在问什么,但我猜你正在寻找这样的东西?:

    echo $this->Html->link(
        $this->Html->image('image.png'),
        array('action' => 'add'),
        array('escape' => false)
    );
    

    我很难想象你会在任何最终产品中实际使用 cake.generic.css 的任何情况,所以 - 不要使用它,写任何你想要的 CSS。

    【讨论】:

    • 这只是一个例子。当然,您对 css 的看法是正确的。试着想象@dave 你的项目中有 45 个类。每个类都有index.ctp、edit、view。尝试将所有链接更改为图片按钮。最好的办法是用css建图,不碰ctp文件。
    • 老实说,@tomas3man,你的要求毫无意义。可能需要尝试用一两个示例重写您的问题。
    • 试着理解。查看文件:cake.generic.css。第 511 行是按钮的定义:input[type=submit], .actions ul li a, .actions a { font-weight:normal; padding: 4px 8px; background: #dcdcdc; background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#dcdcdc)); background-image: -webkit-linear-gradient(top, #fefefe, #dcdcdc); background-image: -moz-linear-gradient(top, #fefefe, #dcdcdc); background-image: -ms-linear-gradient(top, #fefefe, #dcdcdc); background-image: -o-linear-gradient(top, #fefefe, #dcdcdc); background-image: linear-gradient }
    • @tomas3man 试着理解,你写的东西没有明确的问题。
    猜你喜欢
    • 1970-01-01
    • 2016-07-16
    • 2011-09-29
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 2016-07-24
    • 1970-01-01
    • 2012-02-15
    相关资源
    最近更新 更多