[Answered ]-Place (?) tooltip next to field-name Django

1👍

You can put html tags in the help_text, and then use css to render a tooltip. For example,

    fieldName = forms.CharField(help_text="<span class=\"tooltip\">?<span class=\"tooltiptext\">tool_tip_text_to_be_displayed</span></span>")

And then use css like this w3s example:

<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black; 
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  padding: 5px 0;
  border-radius: 6px;
 
  position: absolute;
  z-index: 1;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
</style>

Leave a comment