CSS translation not applied
P粉441076405
P粉441076405 2023-09-12 00:30:06
0
1
513

I need to center my eye icon with my login form input. However, my Top 50% and Translation properties seem to be applied to the main field class instead of inside the input. Therefore, the icon is not aligned within the input field.

.form .field {
  position: relative;
  height: 70px;
  width: 100%;
  margin-top: 24px;
  border-radius: 3px;
}

.field input, .field button {
  height: 70%;
  width: 100%;
  border: none;
  font-size: 14px;
  font-weight: 400;
  border-radius: 3px;
}

.field input {
  outline: none;
  padding: 0 15px;
  border: 1px solid#CACACA;
}

.eye-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  font-size: 18px;
  color: #8b8b8b;
  cursor: pointer;
  padding: 5px;
}
<div class="field input-field">
  <label for="login-pwd">Password</label>
  <input type="password" name="password" class="form-control" placeholder="Password" id="login-pwd" required="">
  <i class="bx bx-hide eye-icon" id="toggle-password"></i>
</div>

Can someone help me solve this problem? I want my icon to be in the center of the input type password.

P粉441076405
P粉441076405

reply all(1)
P粉841870942

You need to give the parent element position:relative;

.input-field {
 position: relative;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template