如何在输入日期字段上模拟占位符功能? [英] How do I simulate placeholder functionality on input date field?

查看:78
本文介绍了如何在输入日期字段上模拟占位符功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在日期字段上使用占位符是不可能的,但我真的需要它。

It's impossible to use placeholder on date fields but I really need it.

我想要两个日期输入,每个输入的文字From和To

I want two date inputs with texts "From" and "To" on each one as placeholders.

推荐答案

  input[type="date"]:before {
    content: attr(placeholder) !important;
    color: #aaa;
    margin-right: 0.5em;
  }
  input[type="date"]:focus:before,
  input[type="date"]:valid:before {
    content: "";
  }

<input type="date" placeholder="Choose a Date" />

这篇关于如何在输入日期字段上模拟占位符功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆