0

目前我的按钮以 Zend 形式使用,我可以弄清楚如何添加标签等,但我现在没有用 HTML 或 CSS 做任何事情。

我的按钮代码如下:

class Application_Form_Newsletter extends Zend_Form
{
    public $processed = false;

    public function init()
    {
        $this->addElement(
            'text', 'email', array(
                'label' => '',
                'required' => true,
                'validators' => array(
                array('StringLength', false, array('max'=>150)),
                'EmailAddress',
                ),
            )
        );

        $this->addElement('submit', 'go', array(

            'id'=>'btnNewsletter',
            'type'=>'image',            
          ));
    }
}

样式表代码如下:

#btnNewsletter{ background-image: url('../img/home-search-background-btn.png');}

我设法让图像显示,但它总是隐藏在实际按钮本身的后面。

4

1 回答 1

1

尝试:

#btnNewsletter {
    background-image: url('../img/home-search-background-btn.png');
    background-color: transparent;
    border: 0;
    text-indent: -1000px;
    padding: 0;
}

还要添加宽度和高度值以匹配按钮的尺寸。该text-indent指令将按钮文本移出视图,以便您看到的唯一内容是图像。

或者,您可以使用图像提交,例如,请参阅此问题:Place an image for submit button in Zend form

于 2013-09-06T12:24:34.260 回答