输入类型=“图像”在 Chrome 中显示不需要的边框,在 IE7 中显示损坏的链接
我还没有找到解决方案...
我尝试了一切
border:0;
border:none;
outline:none;
但没有任何运气...有趣的是 IE7 中的损坏链接图标与我的图像重叠。
有什么建议吗? 链接此处
HTML(由 WordPress 生成)
<form id="searchform" method="get" action="http://eezzyweb.com/">
<div>
<input id="s" name="s" type="text" value="" size="32" tabindex="1"/>
<input id="searchsubmit" name="searchsubmit" type="image" value="" tabindex="2"/>
</div>
</form>
CSS
input#s{
position:relative;
width:245px;
height:28px;
border:0;
vertical-align:bottom;
background:url(images/input-search-bkg.png) 0 0 no-repeat;
}
#searchsubmit {
display:inline-block;
background:url(images/submit-bkg.png) 0 0 no-repeat;
width:30px;
height:30px;
border:0;
vertical-align:bottom;
}
Firefox 和 Opera 可以正常渲染图像按钮,但在 Chrome 和 Safari 中我明白了周围有灰色边框。 IE 7 和 8 在我的图像上添加了一个符号(损坏的图标?)...我很困惑。
I have not found a solution yet...
I tried everything
border:0;
border:none;
outline:none;
without any luck...and the funny thing is the broken link icon in IE7 which overlaps my image.
Any suggestion?
link here
HTML (generated by WordPress)
<form id="searchform" method="get" action="http://eezzyweb.com/">
<div>
<input id="s" name="s" type="text" value="" size="32" tabindex="1"/>
<input id="searchsubmit" name="searchsubmit" type="image" value="" tabindex="2"/>
</div>
</form>
CSS
input#s{
position:relative;
width:245px;
height:28px;
border:0;
vertical-align:bottom;
background:url(images/input-search-bkg.png) 0 0 no-repeat;
}
#searchsubmit {
display:inline-block;
background:url(images/submit-bkg.png) 0 0 no-repeat;
width:30px;
height:30px;
border:0;
vertical-align:bottom;
}
Firefox and Opera render the image button ok, but in Chrome and Safari I get that grey border around it.
IE 7 and 8 add a symbol (broken icon?) over my image... I am baffled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您正在使用该图像作为背景。为什么不将其设置为按钮的 src 属性?
当您将
type
设置为image
时,输入也需要src
属性。参考:http://www.w3.org/TR/html401/interact/forms.html#adef-src 和 http://www.w3.org/ TR/html401/interact/forms.html#h-17.4.1
You are using the image as a background. Why not set it as the src property of the button ?
When you set the
type
asimage
the input expects ansrc
attribute as well..Reference: http://www.w3.org/TR/html401/interact/forms.html#adef-src and http://www.w3.org/TR/html401/interact/forms.html#h-17.4.1
作为参考,如果您想坚持使用 CSS 为按钮提供图像,出于提供 :hover 或 :active 规则等原因,您可以保持代码不变并为按钮添加不可见的图像,我选择了:
这意味着它是完全透明的图像,大小似乎并不重要,但我选择了 1 px x 1px。
For reference, if you want to stick to using CSS to give the button an image, for reasons such as providing a :hover or an :active rule, you can keep your code as is and add the button an invisible image, i went with:
<input type='image' src='invisible.png'/>
Which means its a completly transparent image, size doesnt seem to matter, but i went with 1 px by 1px.
这对我有用:
This worked for me:
Chrome、IE 和 Safari 会愚蠢地解析代码。
不同
这些浏览器的解析方式与将所有图像输入放在编码文档中的同一物理行上 。我刚刚通过我的显示器打了一个完整的同样的问题,直到我意识到这一点。
Chrome, IE, and Safari parse the code foolishly.
is not parsed the same by these browsers as
Put all of your image inputs on the same physical line in the coded document. I just about punched a whole through my monitor with the same problem until I realized this.
这很丑,但它有效......
This is ugly but it works...
试试这个
Try this