Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the calendar icon of an input type date?

I want to know how can I change the calendar logo without using jquery?

I want it to look like in the picture:

this is the image

 input
 {
        width: 50%;
        padding: 8px;
        border-radius: 10px;
        margin-bottom: 5%;
        border: 1px solid #CCCCCC;
        font-size: 13px;
    }
  
  
  
  .fecha input[type="date"]::-webkit-calendar-picker-indicator
  
    {
        color: rgba(0, 0, 0, 0);
        opacity: 1;
        background-image: url("./../some-folder/some-file.svg");
        background-repeat: no-repeat;
        background-position: 100% center;
        background-size: 20px;
        cursor: pointer;
    }
<div class="form-row fecha">
       <div class="col-12">
         <input placeholder="Fecha de Inicio"  type="text" onfocus="  (this.type='date')" onblur="(this.type='text')">
         </div>

but I don't like how it looks, it doesn't look like the picture.

I am working with bootstrap4 (without Jquery) and sass

like image 629
Ale Avatar asked Nov 27 '25 08:11

Ale


1 Answers

/* Styles for wrapping the search box */

.main {
    width: 50%;
    margin: 50px auto;
}

/* Bootstrap 4 text input with search icon */

.has-search .form-control {
    padding-left: 2.375rem;
}

.has-search .form-control-feedback {
    position: absolute;
    z-index: 2;
    display: block;
    width: 2.375rem;
    height: 2.375rem;
    line-height: 2.375rem;
    text-align: center;
    pointer-events: none;
    color: #000;
}
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">



    <title>Hello, world!</title>
  </head>
  <body>
  <div class="row">
  <div class="col-6">
  <div class="input-group">
    <input type="text" class="form-control" placeholder="">
    <div class="input-group-append">
      <button class="btn btn-secondary" type="button">
     <i class="fa fa-calendar" aria-hidden="true"></i>
      </button>
    </div>
  </div>
  </div>
  </div>
  
  <br>
  <p>Other Way using no css</p>
  <!--Another way-->
  <div class="row">
  <div class="col-6">
   <div class="input-group mb-2 mr-sm-2">
   <input type="text" class="form-control" id="inlineFormInputGroupUsername2" placeholder="Username">
    <div class="input-group-append">
     <i class="input-group-text fa fa-calendar" aria-hidden="true"></i>
     
    </div>
    
  </div>
  </div>
  </div>

  
  

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>

please see the above implementation, may be this can help.

like image 106
Deepak Verma Avatar answered Nov 29 '25 21:11

Deepak Verma