I am dynamically adding divs inside #maindiv, and I am never quite sure how many inner divs will end up inside it. Each inner div has a width of 160px. The CSS I'm using for #maindiv is as follows:
#maindiv
{
overflow: auto;
width: 640px;
height: 65px;
background:lightblue;
}
I want #maindiv to display a horizontal scrollbar when the total width of the inner divs exceeds 160px. However, my current CSS setup doesn't seem to be working properly. Despite setting the fixed width for the div, I can't get the horizontal scrollbar to appear. When the inner divs have more combined width than #maindiv, they simply make #maindiv wider. I've also tried implementing max-width:160px for #maindiv but without success. Any suggestions? Thank you in advance.