0

I have a simple input of type text:

<input matInput type="text" placeholder="{{placeholder}}" class="input-field"
    [ngClass]="{'error': hasErrors}" [readonly]="isReadonly" [disabled]="isDisabled">

I've added this css rule for readonly state, using the read-only selectore:

.input-field {
    &:read-only {
        border-style: none;
    }
}

And I have this, which is correct:

enter image description here

The problem is that when I click on the placeholder, the focus event adds the border:

enter image description here

I need to get rid of that border on focus, so using :focus selector I've tried setting border: none but it doesn't work. I've tried:

.input-field {
    &:read-only,:focus {
        border-style: none;
    }
}

and

.input-field {
    &:read-only {
        border-style: none;

      &:focus {
         border-style:none;
      }
    }
}

but the border keeps appearing. I am using Chrome, but I've also tried Firefox and it doesn't work.

2
  • This is an outline, not a border. Commented Jul 9, 2020 at 11:17
  • @cloned still doesn't work with outline:none Commented Jul 9, 2020 at 12:09

1 Answer 1

1

Add this to your focus:

{ outline-style: none; box-shadow: none; border-color: transparent; }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.