I have implemented code that displays a text box when you hover your mouse over specific text. However, the issue I am facing is that the text inside the text box is coming from an attribute of the <a>
tag and I am unable to format it as desired. I intend to create a list within the text box, but it only appears as a continuous block of text.
Here is the HTML structure:
<a data-text="Could use this text instead of title" title="1. ~~~~ List item (/br)~~~~
2. ~~~~ List item ~~~~
3. ~~~~ List item ~~~~
4. ~~~~ List item ~~~~
5. ~~~~ List item ~~~~ " class="tooltip">Hover over this text</a>
Below are the CSS styles applied:
.tooltip{
display: inline;
position: relative;
}
.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(title);
left: 100%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
content: attr(title);
.tooltip:hover:before{
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
You can view a demo of this functionality by visiting: http://jsfiddle.net/h3tqwust/1/
My question is, how can I format the text within the text box to include line breaks?