If its an invasion from the CSA into Mexico, than its no contest: the Mexicans can successfully repel them. Simply put, Dixie is going to be required to keep the majority of her military back home if she perceives the US as a potential threat (Which she inevitably will) who might jump in to support Mexico and retake some ground on the borders (for economic reasons, the US is going to be dead set on getting back the Mississippi down to New Orleans) as well as getting on better terms with France (Which, if she's ticked off at Britain, is a good thing to have given France has the fleet best able to check against the Brits and is currently in some high tension colonial rivalries since the return of the 3rd Republic assuming we haven't butterflied away events in Europe). Given that and the advantages of defensive warfare on their own terrain (to say nothing of the fact Dixie will be attacking out of South Texas at the end of a long, thin longistics line) I doubt they'll even able to break through the Mexican border states before the Imperial army concentrates and becomes the first demonstration of the power of modern artillery in a major war.
If the CSA is facing a hostile USA the war doesn't happen. Some people assume the US will continue to hate the CSA because they lost. But peaceful relations, meaning allowing the US navigation rights on the Missisippi because it is bigger than you in exchange for tax revenue is 'national survival 101' for the South as is decent relations with the North in general (or being armed to the teeth, which precludes a Mexican invasion). So assuming a northern border similar to Canada probably a prerequeset. Maybe they buy US support by offering them Baja or limiting their war goals or has a passible cassus belli. Maybe the CSA simply buys war materiel from US factories.
By the 1880's there is undoubtedly a rail line all the way to El Paso and other border areas, so the logistics is decent.
The CSA probably has maintained a "West Point" meaning a trained officer corps while if otl is anything to go by, Mexico has ineffective aristocrats in officer slots.
What Mexico potentially has is the ability to fight a guerilla war, but the Empire needs the very people who supported Juarez to now support the Imperial government, so this is a "maybe". They may or may not have France. Seeing as Napoleon the 3rd likely looses his throne in 1870, so support may be.....lacking. In fact, owing the CSA money might be a good justification for said war. It was good enough for France after all.
So, the CSA take Chiuahana and Sonora pretty easily and then forces a peace down the Imperial Government's throat. This is followed possibly by a long guerilla war that could go either way.
It doesn't carve up Mexico lest it tick off the USA or England.
Mexico remembers.
Across the course of human history, great conflicts have been fought and promise to be the war to end all wars, and yet every victory has only brought Humiliation, hardship, and bitter resentment to the defeated. So it's only natural the U.S.A seeks revenge for its defeat and Humiliation.
When it's a big enough defeat. As Shelby Foote pointed out, if the South had won, life in the North could have gone on unchanged, rather like Britian after the Revolutionary war. But there is no hardship. There is some resentment but cooler heads say "do we want to fight stupid wars every 20-30 years like Europe?"
The idea that the USA and CSA will default to eternal emnity for no reason (and you can find a reason) is bluntly the single stupidist common trope on these boards and is built on "we really don't like the CSA so naturally everyone will hate them atl as much as we do, just because."
Assuming a victorious CSA's leadership won't industialize, and will not limit its foreign policy ambitions, regardless of what a few "Golden Circle" types dreamed of not very bright either.