Firefox add's 2px padding in a submit button

不打扰是莪最后的温柔 提交于 2019-12-04 06:47:44

I was having a problem like this. I then found this CSS thingy that solved the problem:

input::-moz-focus-inner { border:0; padding:0 }

This solution was given in a comment in this blog post:

Bulletproof CSS input button heights

As the post says: this happens because Firefox (User Agent) own CSS style uses !important and anything one tries to do to override the CSS property won't get applied.

** I leave this here since I think it's useful anywhoo..**

in either case try accessing just the button and play around with the css for it:

input[type="submit"] {
  padding-bottom: 3px;
}

EDIT

Okay so there is a problem with your solution, since you're positioning the image above the button you'll make it harder to actually click the submit-button. If you hover the mouse over the key you'll see that it doesnt change to a pointer = not clickable.

I suggest that you remove the image-tag and instead use it as a background in your submit-button. Something like this:

input[type="submit"] {
  padding-bottom: 3px;
  background: url(path-to-image);
  border: none;
  height: "img-height";
  width: "img-width";
}

If the size of the image is correct, also since you do seem to have some sort of background in the submit button allready. Id go with making an image that is the correct size which contains both the background and the key image (I hope this last sentence makes some sence).

Another possible problem could be that you have no text in your button, however the button should inherit the lineheight/font-size from earlier in the css and thus might expand the submit-button more. Try adding something like font-size: 1px or something.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!