Well, there a number of considerations here, first and foremost being that you can't really legislate attitude. In other words, it is hard to deny someone the right to be an asshole in a free society. Unless a person breaks a law, the U.S. Constitution doesn't really allow for imprisonment or punishment.
Now, there was indeed a Civil Rights Bill that was passed in 1964 which outlawed discrimination based on race, ethnicity, sex, or religion. This was because roughly 100 years had passed since the 13th Amendment outlawed slavery in the United States, and in that time, many citizens, law enforcement officials, legislators, and public institutions had pivoted away from slavery by necessity, and focused their attention on enacting and enforcing institutionalized discrimination that forced many African Americans into a second-class status.
This didn't happen overnight, or in a vacuum, but rather was the result of what you might call a second, sort of municipal Civil War that took place during Reconstruction on the local level in hundreds of towns and cities (with a heavy concentration south of the Mason Dixon line). There was a battle that took place in many localities over the direction of local governance, in that many Republican (northern) appointed governors and judges were seated in traditionally pro-Confederate areas to try and jump-start the new equality era. In some areas, this yielded the desired (northern) results, and things did begin to change for the better. In many places, however, this perception of northern allies coming down to tell defeated southerners how to live their lives smacked of the same "oppression" that they considered to be the impetus of the war in the first place, and many Jim Crow laws and the "racism" I think you are referring to was born anew.
So the Civil Rights Bill that was passed in 1964 was in many ways a remedy to this long-simmering reaction by a bunch of defeated Confederates who couldn't lord over African Americans any longer, so instead decided to codify racism into their southern culture via institutionalized discrimination that took about 99 years to address.
[Sources - Kevin Boyle, 'Arc of Justice'; Bruce Catton, 'A Stillness at Appomattox'; U.S. Grant, Personal Memoirs]