Placeholder Input Date Hack (Pure CSS)

In this example below you will see how to do a Placeholder Input Date Hack (Pure CSS) with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by jodacame, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright jodacame ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Placeholder Input Date Hack (Pure CSS)</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  
<input type="date" placeholder="My Placeholder">
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/jodacame/placeholder-input-date-hack-pure-css-PjQvbJ */

input[type="date"]:before {
   content: attr(placeholder) !important;
   color: rgba(0,0,0,.4);
   margin-right: 0.5em;
   display:block;
 }

/* Your cool style */
body{
  background-color:rgba(0,0,0,.1);
}
input[type="date"]{
  padding:10px 5px 10px 5px;
  border:0px;
  border-bottom:1px solid rgba(0,0,0,.1);
  margin:auto;
  display:block;
  background-color:transparent;
  outline:0;
}

Comments