I am currently working on developing a ticketing system that involves using nested div
elements to organize content. Each ticket is represented by a main div
containing various other nested div
s and media such as images.
While the functionality of the system works properly, I am encountering an issue when it comes to displaying the ticket descriptions. The text within the description div
appears horizontally instead of vertically, causing a horizontal overflow and extending beyond the assigned width of 100%.
The text is enclosed in a span
tag within the description div
, sourced from client-side JSON data and concatenated together like this:
var description = receivedJson.description;
var desDiv = '<div class="description"><span>'+description+'</span></div>';
I suspect that the issue lies in concatenating the text in a single line. Here is a demo, although it does not fully replicate the problem because it does not dynamically substitute text.
Currently, the displayed text causes both horizontal and vertical scrollbars to appear, even if there is no text present. My goal is to only have a vertical scrollbar visible when the text exceeds the height of the div
.
How can I ensure that the text displays vertically within the div
and enable a vertical scrollbar only when necessary?