【CSS】使用css3 :focus 怎样使input的placeholder为空呢?
input文本框中有“请搜索”,设置:focus让input框变色,但其中的placeholder文字没有消失,怎样使placeholder为空呢?
回答:
input:focus::-webkit-input-placeholder{    color:transparent;
}
回答:
如果想要这种效果,可以去掉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>
回答:
这不是 css 能控制的。
当你有键入文字时,placeholder 自己会消失。
回答:
问一下,代码中的
是啥意思,
以上是 【CSS】使用css3 :focus 怎样使input的placeholder为空呢? 的全部内容, 来源链接: utcz.com/a/155149.html








