Как изменить внешний видв хроме - PullRequest
0 голосов
/ 25 апреля 2018

Я создал кнопку выбора даты в виде кнопки, и при наведении на нее это выглядит грязно в браузере Chrome. может быть причина только в поведении по умолчанию в браузерах, но можно ли изменить этот эффект наведения на Chrome?

Изображение в Fire Fox:

По умолчанию <input type=date>

enter image description here

Кнопка <input type=date>

enter image description here

Изображение в Chrome:

По умолчанию <input type=date> (при наведении)

enter image description here

Кнопка <input type=date> (при наведении)

enter image description here

Есть ли способ убрать эффект наведения на хром?

Вход по умолчанию:

<input type="date"  id="myInput">

отредактировано с помощью CSS:

.date-picker-button {
  background: #8DBF42;
  color: #fff;
  position: relative;
  cursor: pointer;
  margin-bottom: 10px;
  border: 2px solid #8DBF42;
  font-size: 14px;
  padding: 12px;
  border-radius: 3px;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  -o-border-radius: 3px;
  width: 300px;
}

.input-group {
  position: relative;
  border: 2px solid #cdd7e1;
  margin-bottom: 10px;
  display: block !important;
  width: 300px;
  border: none;
}

.date-picker-button .date-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: 0;
  background: #8DBF42;
  border: none;
  width: 300px;
  padding-left: 55px;
}

.fa.fa-angle-down {
  float: right;
  color: white;
  font-size: 20px !important;
  font-weight: 600;
  top: 0px !important;
  position: relative;
  margin-right: 20px;
}

.fa-calendar-o {
  color: white !important;
  z-index: 1;
  top: 0px !important;
  position: relative !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="date-picker-button input-group">
  <i class="fa fa-calendar-o" aria-hidden="true"></i>
  <span>Select Date</span>
  <input class="input-startdate date-picker-input hasDatepicker" name="effdate" id="dp1523936970319" aria-required="true" required="" type="date">
  <i class="fa fa-angle-down" aria-hidden="true"></i>
</div>

Ответы [ 3 ]

0 голосов
/ 25 апреля 2018

Попробуйте, все будет скрыто:

input#myInput::-webkit-calendar-picker-indicator { display: none }

input[type=date]::-webkit-inner-spin-button, 
input[type=date]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
0 голосов
/ 25 апреля 2018

Вы можете следовать этому ответу: Метод для отображения собственного средства выбора даты в Chrome , который показывает, как можно растянуть стрелку по всему входу, что позволяет затем щелкнуть мышью в любом месте поля ввода, чтобы вызвать средство выбора даты.

0 голосов
/ 25 апреля 2018

Это работает, чтобы скрыть кнопки ввода:

::-webkit-inner-spin-button,
::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}
<input type="date"  id="myInput">
...