4 回答

TA贡献1851条经验 获得超4个赞
如果要使用CSS为按钮设置样式,请将其设置为type =“ submit”按钮,而不是type =“ image”。type =“ image”需要一个SRC,您无法在CSS中设置它。
请注意,Safari不允许您以所需的方式设置任何按钮的样式。如果需要Safari支持,则需要放置图片并具有提交表单的onclick函数。

TA贡献1821条经验 获得超6个赞
的HTML
<div class="myButton"><INPUT type="submit" name="" value=""></div>
的CSS
div.myButton input {
background:url(/images/Btn.PNG) no-repeat;
cursor:pointer;
width: 200px;
height: 100px;
border: none;
}
即使在Safari中也可以在任何地方使用。

TA贡献1829条经验 获得超13个赞
本文有关CSS图像替换提交按钮的文章可能会有所帮助。
“使用这种方法,当样式表处于活动状态时,您将获得一个可点击的图像,而当样式表处于关闭状态时,将获得一个标准按钮。诀窍是将图像替换方法应用于按钮标签,并将其用作提交按钮,而不是使用的输入。
而且,由于按钮的边界被擦除,这也是可推荐的变化的按钮光标形一个用于链接的手,因为这提供了一个可视前端到用户“。
CSS代码:
#replacement-1 {
width: 100px;
height: 55px;
margin: 0;
padding: 0;
border: 0;
background: transparent url(image.gif) no-repeat center top;
text-indent: -1000em;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}
#replacement-2 {
width: 100px;
height: 55px;
padding: 55px 0 0;
margin: 0;
border: 0;
background: transparent url(image.gif) no-repeat center top;
overflow: hidden;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}
form>#replacement-2 { /* For non-IE browsers*/
height: 0px;
}
- 4 回答
- 0 关注
- 455 浏览
相关问题推荐
添加回答
举报