CSS :after input placeholder not working in mozilla

限于喜欢 提交于 2019-12-29 09:16:07

问题


I want to put a small icon in my text input placeholder right where my placeholder text ends

<input type="text" placeholder="Search  ">

With CSS I want to add a magnifier icon. This works perfectly in Chrome, but I want to make it work for Firefox as well.

For Chrome I used ::-webkit-input-placeholder:after{content:url('magnifier.jpg');} And with Firefox I've tried

input:-moz-placeholder:after{content:url('magnifier.jpg');}

and

input:-moz-placeholder::after{content:url('magnifier.jpg');}

but for some reason it's not working.


回答1:


.......................

Input elements are replaced elements.

Pseudo-elements, such as :after or :before will not work on

 <button>, <textarea>, <input>,  <select>, <img>, <object> 

these elements.

More info




回答2:


Don't try to add the image as content. Use

input:-moz-placeholder { background: url('magnifier.jpg') right center no-repeat }

and tweak the background properties to taste.



来源:https://stackoverflow.com/questions/12834939/css-after-input-placeholder-not-working-in-mozilla

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