Firefox 在文本字段顶部添加了一个额外的像素,如何删除它?

发布于 2024-09-08 11:16:07 字数 431 浏览 4 评论 0原文

我想创建一个像本页中的搜索栏 http://dl. dropbox.com/u/333492/search/form.html

如果您使用 chrome、opera 或 safari 加载该页面,搜索栏看起来应该如此(在 Mac 上测试)。但是,如果您使用 Firefox(至少在 mac 上使用 ff 3.5 和 3.6 进行过测试),您会看到在文本字段顶部添加了一个额外的像素,因此文本字段比按钮低 1 个像素,这看起来很丑。

我尝试删除所有可能的边框和填充,但问题仍然存在。我还注意到,当搜索按钮不存在时,它不会发生。

有人知道可能导致这种行为的原因吗?或者,更好的是,有人可以更改该页面上的 CSS 以便解决问题吗?

I want to create a search bar like one in this page http://dl.dropbox.com/u/333492/search/form.html

If you load that page with chrome, opera or safari, the search bar looks like it should (tested on mac). However, if you use firefox (tested at least with ff 3.5 and 3.6 on mac), you'll see that one extra pixel gets added on top of the text field, and thus the text field is one pixel lower than the button, which looks ugly.

I tried to remove all possible borders and paddings but the problem persists. I also noticed that it doesn't occur when the search button is not there.

Does someone have any idea on what might be causing this behavior? Or, even better, could someone alter the CSS on that page so that the problem would be fixed?

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

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

发布评论

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

评论(1

淡紫姑娘! 2024-09-15 11:16:07

我终于找到了一篇博客文章,解释了问题的原因并提出了部分解决问题的答案。感谢 Twitter 上的@anttisykari!

http://christophzillgens。 com/en/articles/equal-height-input-and-button-elements-in-firefox-and-safari

所以正确的答案是在 CSS 中添加以下几行:

 input[type="submit"]::-moz-focus-inner {border:0;} /* ff specific stuff, yuck*/ 
 input[type="submit"]:focus {background:#333;} /* change accordingly depending on your button bg color, this fixes the focus problem when using keyboard to move betweenform elements */

但是,IE8 仍然破坏了我的表单,所以我必须将它们添加到两个输入元素中。

 display: block;
 position: relative;
 float: left;

现在一切似乎都好起来了。

I finally found a blog post that explains the cause of the problem and proposes an answer that partially fixes the situation. Thanks @anttisykari in Twitter!

http://christophzillgens.com/en/articles/equal-height-input-and-button-elements-in-firefox-and-safari

So the correct answer is to add following lines to the CSS:

 input[type="submit"]::-moz-focus-inner {border:0;} /* ff specific stuff, yuck*/ 
 input[type="submit"]:focus {background:#333;} /* change accordingly depending on your button bg color, this fixes the focus problem when using keyboard to move betweenform elements */

However, IE8 still broke my form, so I had to add these to both input elements.

 display: block;
 position: relative;
 float: left;

Now everything seems to be ok.

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