Our objective is to have two divs aligned next to each other.
Here is the HTML code:
<div class="test1>Text 1</div>
<div class="test2>Text 2</div>
And here is the CSS code:
.test1 {
float: left;
}
.test2 {
float: left;
}
This setup works well when the browser window is wider than the combined width of the two divs. However, if the browser window becomes too narrow to accommodate both divs side by side, test2 will be pushed below test1.
What can we do to prevent this from happening? Is it possible to keep them consistently aligned next to each other, even if they exceed the width of the browser window (potentially showing a horizontal scroll bar)?