I don't know about foxes, but it took one of those bins with clips
and a strong bungee to hold the clips shut to stop our naughty and greedy GSD x collie raiding our dustbin. But that combination did work.
Or you can try what my dad did with a neighbouring marauding cat when I was a kid. We had the old metal dustbins, and the cat could get the lid off. We'd hear the clatter and the cat would be in the bin, raiding.
Dad sat in wait, shovel at the ready. He took the lid off to make it easier for the cat to jump into the 1/4-full bin, in which tasty fishy morsels wafted appealing scents...
The cat duly appeared and jumped in the bin. Dad whanged the bin with the shovel with all his might. It was Tom and Jerry Live - a star-shaped legs, tail and spiky haired creature, accompanied by a night-rending scream, appeared as if fired out of the bin, for a split second was static in spiky terror a foot above the rim, then it disappeared in an instant, never to be seen in our garden again.
For a while I thought the three of us would end ourselves laughing. I've tears in my eyes now.