Remove default text/placeholder present in html5 input element of type=date

前端 未结 10 2293
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 19:32

I am using html input element with type as date,


When I use above element it creates a default date format i.e.

10条回答
  •  被撕碎了的回忆
    2020-11-27 20:15

    The accepted answer doesn't seem to work anymore on latest chrome versions. Tested it on Version 50.0.2661.102 and didn't work.

    Works by adding this instead:

    .mdl-textfield:not(.is-dirty) input::-webkit-datetime-edit {
         color: transparent; 
    }
    
    input:focus::-webkit-datetime-edit {
        color: rgba(255, 255, 255, .46) !important; 
    }
    

    Working sample

    Source

提交回复
热议问题