Невозможно удалить значок галочки из ввода - PullRequest
0 голосов
/ 07 августа 2020

Я создал переключатель, и теперь его поведение правильное, но у меня небольшая проблема с пользовательским интерфейсом, и я не могу понять, что это такое.

enter image description here

I have circled in red the issue I have, It's really minor but it's annoying. I do not want those check icons.

here is the code:

const Switch = 
             {TextContents.CreditsBundle}   {TextContents.SubscriptionsBundle}    

и css связанный

.switch-field {
  display: flex;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  }

.switch-field-element {
  position: relative;
  height: 80px;

}

.switch-field-element:not(:first-of-type) {
  margin-left: -60px;
}
  
  
  .switch-field input {
      position: absolute;
      height: 100%;
      width: 100%;
      opacity: 0;
  }
  
  .switch-field label {
    display: inline-block;
    position: relative;
    padding: 0px 80px;
    background-color:#f4f7f8;
    height: 50px;
    line-height: 50px;
    cursor: pointer;
    transition: all .1s;
    color: #dfdfdf;
    user-select: none;
    border-radius: 40px;
    font-size: 20px;
    font-weight: bold;
    font-family: Source Sans Pro;
  }

  .switch-field label::after {
    content: '';
    display: block;
    position: absolute;
    width: 4px;
    height: 8px;
    border-bottom: 2px solid white;
    border-right: 2px solid white;
    transform: rotate(45deg);
  }
  
  .switch-field input:checked + label {
    background-color: var(--village-color-blue);
    border-color: var(--village-color-blue);
    color: white;
    z-index: 1;
    box-shadow: 0px 15px 20px -2px rgba(black, .1);
  }
  
  .switch-field label:first-of-type {
    padding-right: 80px;
  }

  .switch-field label:first-of-type::before {
    right: 0;
    top: 0;
  }

  .switch-field label:first-of-type::after {
    right: 12px;
    top: 9px;
  }
  
  .switch-field label:last-of-type {
    padding-left: 80px;
  }

  .switch-field label:last-of-type::before {
    left: 0;
    top: 0;
  }

  .switch-field label:last-of-type::after {
    left: 12px;
    top: 9px;
  }

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

Ответы [ 2 ]

1 голос
/ 07 августа 2020

Вы можете скрыть видимость ваших переключателей.

Попробуйте следующее:

input[type="radio"]:checked{
   visibility:hidden;
}
0 голосов
/ 07 августа 2020

Вы можете изменить в соответствии с вашими требованиями - Живая рабочая демонстрация

 <form className="switch-field">
          <div className="switch-field-element">
            <input
              type="radio"
              id="switch_left"
              name="switchToggle"
              value={TextContents.CreditsBundle}
              onChange={this.toggleState}
              checked={!this.state.toggle}
            />
            <label
              className={toggle ? "lightgrey" : "blue selected"}
              htmlFor="switch_left"
            >
              {TextContents.CreditsBundle}
            </label>
          </div>

          <div className="switch-field-element">
            <input
              type="radio"
              id="switch_right"
              name="switchToggle"
              value={TextContents.SubscriptionsBundle}
              onChange={this.toggleState}
              checked={this.state.toggle}
            />
            <label
              className={!toggle ? "lightgrey" : "blue selected"}
              htmlFor="switch_right"
            >
              {TextContents.SubscriptionsBundle}
            </label>
          </div>
        </form>

css

.switch-field {
  display: flex;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.switch-field-element {
  position: relative;
  height: 80px;
}

.switch-field-element:not(:first-of-type) {
  margin-left: -60px;
}

.switch-field input {
  position: absolute;
  height: 100%;
  width: 100%;
  opacity: 0;
}

.switch-field label {
  display: inline-block;
  position: relative;
  padding: 0px 80px;
  background-color: #f4f7f8;
  height: 50px;
  line-height: 50px;
  cursor: pointer;
  transition: all 0.1s;
  color: #dfdfdf;
  user-select: none;
  border-radius: 40px;
  font-size: 20px;
  font-weight: bold;
  font-family: Source Sans Pro;
}

.selected::after {
  content: "";
  display: block;
  position: absolute;
  width: 9px;
  height: 17px;
  border-bottom: 2px solid white;
  border-right: 2px solid white;
  transform: rotate(45deg);
  top: 10px;
  left: 20px;
}
.switch-field .uncheck label::after {
  left: 12px;
  top: 9px;
}
.switch-field input:checked + label {
  background-color: var(--village-color-blue);
  border-color: var(--village-color-blue);
  color: white;
  z-index: 1;
  box-shadow: 0px 15px 20px -2px rgba(black, 0.1);
}

.switch-field label:first-of-type {
  padding-right: 80px;
}

.switch-field label:last-of-type {
  padding-left: 80px;
}

.switch-field label:last-of-type::before {
  left: 0;
  top: 0;
}

.lightgrey {
  background-color: #f4f7f8 !important;
}
.blue {
  background: #07b6d2c7 !important;
}

рабочий код

Выход

введите описание изображения здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...