input文本框中有“请搜索”,设置:focus让input框变色,但其中的placeholder文字没有消失,怎样使placeholder为空呢?
input文本框中有“请搜索”,设置:focus让input框变色,但其中的placeholder文字没有消失,怎样使placeholder为空呢?
如果想要这种效果,可以去掉placeholder,写一个标签模拟placeholder。粗略地写了一下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
position: relative;
}
label {
position: absolute;
left: 5px;
color: #ccc;
}
input:focus + label {
display: none;
}
</style>
</head>
<body>
<div>
<input type="text">
<label>sfsdfsaf</label>
</div>
</body>
</html>
10 回答11.1k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
5 回答1.9k 阅读