问题
I have a modal and inside that modal I have a checkbox which is acting like a switch button.I want to show a tooltip for that checkbox when I will hover on it.How to do this . Title is not working here.
My markup is like this.
<input id="chkSyncType" title="The tooltip" type="checkbox" class="make-switch" data-on-color="success" data-on-text=" Auto " data-off-text=" Manual " value="false" checked="checked" />
Final html is
<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-on bootstrap-switch-id-chkSyncType bootstrap-switch-animate" style="width: 161.818px;"><div class="bootstrap-switch-container" style="width: 240px; margin-left: 0px;"><span class="bootstrap-switch-handle-on bootstrap-switch-success" style="width: 80px;"> Auto </span><span class="bootstrap-switch-label" style="width: 80px;"> </span><span class="bootstrap-switch-handle-off bootstrap-switch-default" style="width: 80px;"> Manual </span><input id="chkSyncType" title="mytooltip" type="checkbox" class="make-switch" data-on-color="success" data-on-text=" Auto " data-off-text=" Manual " value="false" checked="checked"></div></div>
回答1:
If you want to display the title as a tooltip, you can do something like this.
input {
position: relative;
}
input::after {
content: attr(title);
display: block;
/* just for demo purposes :) */
transition: all .3s;
opacity: 0;
position: absolute;
background: tomato;
color: white;
padding: 0.5rem 1rem;
bottom: -3rem;
}
input:hover::after{
opacity: 1;
}
<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-on bootstrap-switch-id-chkSyncType bootstrap-switch-animate" style="width: 161.818px;"><div class="bootstrap-switch-container" style="width: 240px; margin-left: 0px;"><span class="bootstrap-switch-handle-on bootstrap-switch-success" style="width: 80px;"> Auto </span><span class="bootstrap-switch-label" style="width: 80px;"> </span><span class="bootstrap-switch-handle-off bootstrap-switch-default" style="width: 80px;"> Manual </span><input id="chkSyncType" title="mytooltip" type="checkbox" class="make-switch" data-on-color="success" data-on-text=" Auto " data-off-text=" Manual " value="false" checked="checked"></div></div>
来源:https://stackoverflow.com/questions/42996621/showing-tooltip-for-a-checkbox-inside-a-modal