Yes to be clear the Democrats achieved their Congressional majorities back in the day through a bargain where southern Democrats agreed to go along with northern Democrats' economic policy agenda in exchange for northern Democrats protecting southern Democrats' efforts at perpetuating a racist apartheid regime. As the power and number of the northern liberals increased, they eventually didn't need to support the southern Democrats' racism anymore and ditched it. Then the racist southern Democrats switched to the Republican Party, which welcomed their racism.
To be fair, it was a little more that they were forced to drop the Southern racism and less that they just discarded it out of lack of necessity. It took the Civil Rights Movement for them to actually do that, and frankly if JFK, RFK, and MLK Jr hadn't been assassinated, I'm not sure that we would have seen things actually change, but those were enough to get most Americans to realize that oh, we really do need to address this hatred. Racism is unfortunately too deeply seeded in America (that's not "both sides!"-ing it, its just saying that while conservatives definitely are much worse about it, there's too high of prevalence across the spectrum of America's culture that has partaken in and even to this day still supports in some manner, bigotry especially racism and sexism).