Encountering an unusual issue where the height of a div is not updating when content is appended to it using JQuery. To demonstrate the problem, I have created a simple JSFiddle:
Here is the initial HTML structure:
<div id="container">
SomeContent
</div>
After appending content:
<div id="container">
SomeContent
<div class="dateDiv date1">
<span class="dateTitle">Date2</span><br>09/10
</div>
<div class="dateDiv date2">
<span class="dateTitle">Date2</span><br>10/12
</div>
</div>
CSS styling for the added elements:
div.dateDiv {
border: 1px solid black;
width: auto;
text-align: center;
padding: 5px;
}
div.date1 {
float: left;
}
div.date2 {
float: right;
}
The content is appended in this manner:
$("#container").append("<div class='dateDiv date1'><span class='dateTitle'>Date1</span><br>09/10</div>");
$("#container").append("<div class='dateDiv date2'><span class='dateTitle'>Date2</span><br>10/12</div>");
Speculating whether the "float" CSS property may be causing this issue. Seeking insights and solutions as I am not well-versed with float properties.
Any suggestions or ideas on how to address this?