HTML5 Search Input: No Background Image in Chrome?

前端 未结 4 786
情深已故
情深已故 2020-12-28 08:06

I have been pulling my hair out trying to get Chrome to style my search input with a background image. Firefox has no problem, but I fear it\'s because it treat

4条回答
  •  天涯浪人
    2020-12-28 08:45

    You can get Chrome (and Safari) to play along better with your styles on an HTML5 search field (including background images) if you apply this in your CSS:

    -webkit-appearance: none;

    You may also want to change -webkit-box-sizing to...

    -webkit-box-sizing: content-box;

    ...since it appears that Webkit defaults this to the border-box value (basically the old IE5 box model).

    Be warned, there's still no (apparent) way to have any effect on the position/appearance of the field-clearing button, and since only Webkit generates that button, you may find some new cross-browser annoyances to deal with.

提交回复
热议问题