【问题标题】:Is it possible to make the placeholder attribute of an input element remain the same even after entering a value是否可以使输入元素的占位符属性在输入值后保持不变
【发布时间】:2020-10-07 01:24:21
【问题描述】:

在我正在制作的网站中,我将输入元素的占位符属性设置为向上翻译。我想知道即使在元素中输入文本后是否可以保持占位符属性相同。

这是我的 CSS

.inputbox {
    height: 40px;
    padding-top: 5px;
    border-style: none none double none;
    border-color: rgb(117, 117, 117);
    width: 200px;
    outline: none;
    transition: border-color 0.3s;
}

.inputbox:focus {
    border-color: #111;
}

.inputbox::placeholder {
    transition: all 0.3s;
}

.inputbox:focus::placeholder {
    transform: translateY(-20px);
    color: #111;
    transition: all 0.3s;
}

【问题讨论】:

  • “相同”是什么意思,输入值后占位符值不应该消失吗?请详细说明。
  • 是的,确实如此。我想知道在元素中输入一些输入后是否可以防止占位符消失。
  • 会不会使输入的文本难以理解,因为它会与占位符重叠?
  • 我使用 css 将其向上移动,使其不会重叠

标签: javascript html css placeholder


【解决方案1】:

我认为在输入一些文本后保留占位符属性是不可能的。我可以解决它的最好方法是使用<label> 标签。

【讨论】:

    猜你喜欢
    • 2011-07-16
    • 2018-04-10
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-05
    • 1970-01-01
    • 2016-05-24
    • 2011-04-24
    相关资源
    最近更新 更多