输入 CSS 在 Chrome、Safari 和 Internet Explorer 中显示边框且无文本

发布于 2024-10-31 02:54:37 字数 752 浏览 0 评论 0原文

我正在使用这个输入

<input src="img/buttons1.png" name="submit" class="submit1" type="image" value="See Today's Date Deal" tabindex="502" />

,这里的 css

.submit1 {
              display: block;
              width: 250px;
              height: 28px;
              background: url(img/buttons1.png) no-repeat 0 0;
              padding-top: 12px;
              text-align: center;
              font-size: 17px !important;
              color:#fff; 
              border:0;
              outline:none;
}

在 Firefox 中看起来很棒,但在 Chrome、Safari 和 Internet Explorer 中它是 http:// /screencast.com/t/PsWmBZA8J
我想删除边框并显示文本。

任何建议都会很棒!谢谢

I'm using this input

<input src="img/buttons1.png" name="submit" class="submit1" type="image" value="See Today's Date Deal" tabindex="502" />

and here it's the css

.submit1 {
              display: block;
              width: 250px;
              height: 28px;
              background: url(img/buttons1.png) no-repeat 0 0;
              padding-top: 12px;
              text-align: center;
              font-size: 17px !important;
              color:#fff; 
              border:0;
              outline:none;
}

In Firefox looks great but in Chrome, Safari and Internet Explorer it is http://screencast.com/t/PsWmBZA8J
I'd like to remove border and show text.

Any suggestion would be great! Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

魂牵梦绕锁你心扉 2024-11-07 02:54:37

您已在 上使用了 CSS 背景属性和 src 属性。 src 链接无效,因此浏览器显示损坏的图像占位符。这在每个浏览器中看起来都不同,即您看到的边框和小问号。 IE 显示一个小红十字和一个边框。

要么使用 并使用 CSS 背景属性,要么使用 >

请参阅此演示,其中第一个按钮的src< /code> 属性,并显示占位符以及 CSS 背景图像。而第二个按钮是一个提交按钮,没有 src,只有背景图像的正确 URL。

编辑:之前已被问过:如何使用更改输入按钮图像CSS?input type="image" 在 Chrome 中显示不需要的边框,在 IE7 中显示损坏的链接

You have used both a CSS background property and the src attribute on the <input>. The src link is invalid so the browser is displaying the broken image placeholder. This looks different in every browser which is the border and small question mark you are seeing. IE shows a little red cross and a border.

Either make it <input type="submit"/> and use the CSS background property or use <input type="image" src=""/>

See this demo where the first button has a broken src attribute, and is showing the placeholder as well as the CSS background image. Whereas the second button is a submit button without the src and just the correct URL for the background image.

Edit: This has been asked before: How to change an input button image using CSS? and input type="image" shows unwanted border in Chrome and broken link in IE7

舟遥客 2024-11-07 02:54:37

确保图像文件夹的路径正确。使用 ../ 向上一级目录,使用 / 向上到主目录。

make sure that the path to your images folder is the right one. use ../ to go up one directory, and / to go up to the main directory.

北凤男飞 2024-11-07 02:54:37

这是表单上的输入:

<input type="submit" id="submit" class="submit-btn" style="margin-top:5px" border="0" value=" ">

这是我的 CSS:

.submit-btn {
    background: url("images/submit.png") no-repeat 0 0 transparent;
height:35px;
width:142px;
display:block;
border: 0 none;
}
.submit-btn:hover {
background: url("images/submit.png") no-repeat 0 -35px transparent;
height:35px;
width:142px;
display:block;
border: 0 none;
}

问题也可能是,如果您不告诉它是透明的,浏览器将默认看起来像边框的白色背景。

here's the input on the form:

<input type="submit" id="submit" class="submit-btn" style="margin-top:5px" border="0" value=" ">

and here is my CSS:

.submit-btn {
    background: url("images/submit.png") no-repeat 0 0 transparent;
height:35px;
width:142px;
display:block;
border: 0 none;
}
.submit-btn:hover {
background: url("images/submit.png") no-repeat 0 -35px transparent;
height:35px;
width:142px;
display:block;
border: 0 none;
}

the issue can also be that if you don't tell it to be transparent, the browser will default a white background which looks like a border.

对不⑦ 2024-11-07 02:54:37

也许你应该使用 type="button"。代码将是:

<input name="submit" class="submit1" type="button" value="See Today's Date Deal" tabindex="502" />

CSS 将保持原样。

Maybe you should use type="button". The code would be:

<input name="submit" class="submit1" type="button" value="See Today's Date Deal" tabindex="502" />

And the CSS would remain as-is.

自演自醉 2024-11-07 02:54:37

我也在寻找这个问题的解决方案。

人们可能特别需要一个,因为这样在一种表单中可以有两个提交按钮。
使用背景图像 iso src 属性的原因是 Sprite。 (悬停时背景位置发生变化)。

当你想要这一切时,你仍然必须使用有效的 src 属性,因为至少 Chrome 期望它摆脱输入周围的这条线,它不是边框,也不是轮廓。所以我使用 1 像素透明 gif 作为 src 属性来满足 Chrome。

I was looking for a solution to this problem as well.

One could specifically want an <input type="image"> because one can have two submit buttons in one form that way.
The reason to use a background image i.s.o. src attribute is Sprite. (background position shifting on hover).

When you want all this, you still have to use a valid src attribute, since it is expected - by Chrome at least - to get rid of this line around the input, which is not a border, nor an outline. So i use a 1 pixel transparent gif for the src attribute to satisfy Chrome.

甜尕妞 2024-11-07 02:54:37

您是否尝试过设置 border:0px 而不是 0 ?

Have you tried setting border:0px instead of just 0?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文