扫码关注官方订阅号
input文本框中有“请搜索”,设置:focus让input框变色,但其中的placeholder文字没有消失,怎样使placeholder为空呢?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
input:focus::-webkit-input-placeholder{ color:transparent; }
如果想要这种效果,可以去掉placeholder,写一个标签模拟placeholder。粗略地写了一下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> p { position: relative; } label { position: absolute; left: 5px; color: #ccc; } input:focus + label { display: none; } </style> </head> <body> <p> <input type="text"> <label>sfsdfsaf</label> </p> </body> </html>
这不是 css 能控制的。
当你有键入文字时,placeholder 自己会消失。
问一下,代码中的
是啥意思,
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
如果想要这种效果,可以去掉placeholder,写一个标签模拟placeholder。粗略地写了一下
这不是 css 能控制的。
当你有键入文字时,placeholder 自己会消失。
问一下,代码中的
是啥意思,