Home > database >  How to make the CSS :focus work on my project?
How to make the CSS :focus work on my project?

Time:01-23

Can anyone help me? I tried to add a border-color using :focus on the form input when the user clicks on the text field. But it doesn't work. Any help is really appreciated. Thank you!

form.customNewsletter-form {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  gap: 16px;
}

form.customNewsletter-form input[type="text"] {
  font-family: "Roboto", sans-serif;
  font-size: 16px;
  font-weight: 300;
  color: #ffffff;
  background-color: #0d0d0d;
  border: 1px solid #404040;
  width: 70%;
  height: 48px;
  padding: 0 16px;
  letter-spacing: 0.8px;
  border-radius: 4px;
  margin: 0;
}

form.customNewsletter-form input[type="text"]:focus {
  border: 1px solid #cd0d0d;
}

form.customNewsletter-form input::placeholder {
  color: #8d8d8d;
}

form.customNewsletter-form input[type="submit"] {
  color: #ffffff;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 16px;
  font-weight: 300;
  background-color: #cd0d0d;
  border: none;
  border-radius: 4px;
  height: 48px !important;
  width: 30%;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 0 auto !important;
  transition: 0.3s all ease;
}

form.customNewsletter-form input[type="submit"]:hover {
  background-color: #8e0000;
  color: #ffffff;
  -webkit-transform: scale(0.99);
  transform: scale(0.99) 0.5s ease-in;
}
<form  action="https://app.getresponse.com/add_subscriber.html" accept-charset="utf-8" method="post">
  <!-- Email field (required) -->
  <input type="text" name="email" placeholder="Enter your email">
  <!-- List token -->
  <!-- Get the token at: https://app.getresponse.com/campaign_list.html -->
  <input type="hidden" name="campaign_token" value="sample">
  <!-- Thank you page (optional) -->
  <input type="hidden" name="thankyou_url" value="https://www.website.com/thankyou">
  <!-- Add subscriber to the follow-up sequence with a specified day (optional) -->
  <input type="hidden" name="start_day" value="0">
  <!-- Subscriber button -->
  <input type="submit" value="Subscribe">
</form>

Please see here for the demo.

I'm expecting the border-color of the input field to change to red when the user clicks on it.

CodePudding user response:

Add outline:none;

form.customNewsletter-form input[type="text"]:focus {
  outline: none;
  border: 1px solid #cd0d0d;
}
  • Related