It's true that many Southern Democrats opposed Civil Rights legislation and some supported segregation. However, roughly two-thirds of Democrats in both chambers supported the landmark legislation.
The bill was called for by President John F. Kennedy in his civil rights speech of June 11, 1963, in which he asked for legislation "giving all Americans the right to be served in facilities which are open to the public—hotels, restaurants, theaters, retail stores, and similar establishments," as well as "greater protection for the right to vote."
After Kennedy's assassination, President Johnson used his experience as a former Senator to push the bill through in just a few months. It's clear that without the moral and political leadership of Presidents Kennedy and Johnson, this legislation would not have seen the light of day.
Prior to 1963 the former states of the Confederacy had been known as "The Solid South" because of the virtually complete control by the Democratic Party over local, state and federal offices. Passage of this legislation led those opposed to equality for African Americans to leave the Democratic Party and join the Republican party.