I need to display a tooltip on a disabled button and remove it on an enabled button. Currently, it works in reverse.
What is the best way to invert this behaviour?>
You can imitate the effect using CSS3.
Simply take the disabled state off the button and the tooltip doesn't appear anymore.. this is great for validation as the code requires less logic.
I wrote this pen to illustrate.
CSS3 Disabled Tooltips
[disabled] {
&[disabled-tooltip] {
cursor:not-allowed;
position: relative;
&:hover {
&:before {
content:'';
border:5px solid transparent;
border-top:5px solid black;
position: absolute;
left: 50%;
transform: translate(-50%, calc(-100% + -5px));
}
&:after {
content: attr(disabled-tooltip);
position: absolute;
left: 50%;
transform: translate(-50%, calc(-100% + -15px));
width:280px;
background-color:black;
color:white;
border-radius:5px;
padding:8px 12px;
white-space:normal;
line-height:1;
}
}
}
}