Home > OS >  Hide disabled button using css
Hide disabled button using css

Time:07-02

I am trying to hide "left-arrow" when it is disabled. However i can't seem to get the CSS right.

[data-tour-elem="left-arrow"] {
    display: none;
}

enter image description here

CodePudding user response:

You are using it wrong. You have to use the : selector, not ..

button {
  border: 5px solid lime;
}

button:disabled {
  border: 5px solid aqua;
}
<button>
  Not disabled
</button>

<button disabled>
  Disabled
</button>

<button onclick="this.disabled = true;">
   Click to disable
</button>

This code gives the active buttons a lime border, and the disabled ones an aqua border.

You can learn more about CSS selectors: MDN CSS selectors MDN disabled selector DevDocs disabled selector

  •  Tags:  
  • css
  • Related