Is that true of LA? It's only the case if there's no reasonable neighborhood within the boundaries of LA you could move to after an untenable rent increase in your current neighborhood.
For instance: it's obviously not the case that middle class families are priced out of the Chicago market. Chicago is full of neighborhoods full of hours and townhomes and three-flats that span pretty much the whole price spectrum. On the other hand: some neighborhoods that were pretty reasonable 10 years ago (Roscoe Village, or Bucktown) are now so expensive that their demography is changing. That doesn't mean Chicago is pricing out middle class families; it means Bucktown is.
There are certainly areas of LA at least as big as the total area of SF where middle class families can not afford to live. There are also areas at least as big as the total area of SF where lower-middle class families are the vast majority of residents.
The cities are just too different to make a meaningful comparison in my opinion.
Median household income for city of LA is ~$60k. Without detailing the numbers, maybe if you're really liberal with mortgage qualification you get a $450k home at that income (house or condo). In a broad Redfin search of the Valley/LA Basin and a bit beyond to the east/south (this includes many cities outside of LA), you have:
Total homes for sale: 4,720 <$450k: 873 (18%) In Safe Neighborhoods: 294 (6%) (I used my own definition of safe, but it's very liberal and includes many places where walking around after dark alone would not be advised, but it's an urban area after all so that's understandable)
Btw, and this is where people say you're not entitled to something, but if you are just talking about single family homes (LA is very single family home-focused) in a safe hood for <450k the number of availabilities drops to 51 homes (that's 1% of inventory).
Lots of other nuances here, but just a broad brushstroke look at the market.
What's Bayview like in San Francisco these days?
The better question is do middle class families have to live as far away from their jobs in LA as they do in SF, and the answer to that question is increasingly "yes."
I just moved out of a place in Studio City, paying $1200 for a small one-bedroom apartment. It's listed now for $1600, and I'd bet on it filling within 10 days.
So that's a 1/3 increase in rent I was able to avoid by staying in one place for a long while, but if I'd been moving around it would have cost much more over the years.
In the far (semi-rural) reaches of Sacramento now, and happier for it!