css怎么让输入框不显示光标?
网上有很多方式:用div模拟,设置readonly,设置disabled,设置自动blur等等方式,发现都不能满足需求,最后还是找到一位大神提供的方法完美解决。
一、首先隐藏光标
<style> input{ color: transparent; } </style>
因为光标是跟随文字的,所以我们把文字的color设置为透明,光标就不见了。
(相关课程推荐:css视频教程)
二、把文字给显示出来
<style> input{ color: transparent; text-shadow: 0 0 0 #000; } </style>
在input上设置text-shadow,文字是透明的但是我们可以用文字阴影来代替文字的颜色,这样就完美解决了。
参考链接:https://blog.csdn.net/zy1281539626/article/details/80408928
© 著作权归作者所有
举报
发表评论
0/200