Easy way to earthquake proof things sitting on a shelf

I have a bunch of mugs/glassware I have on display on shelves around my house, the shelves are basically flat boards protruding from the wall. My mugs/glasses basically have a few inches of space before they reach the edge of the board and there’s nothing holding them back from just falling straight off.

I’ve always been concerned about what would happen if during an earthquake (Southern California homeowner) they were all to fall off the shelves and smash on the ground. Granted the last time we had a major earthquake here (6.0) none of them actually did, but I’m curious if there’s like an easy way to put a kid on the edge of the boards just to hold them back from falling from minor shakes. I know they won’t hold together during a serious earthquake but during an event like that I imagine even stuff in my glass cabinets won’t have any better chance of surviving either.

Fun-Tak.

Are they just for display? If you don’t expect to move them, you can attach them to the shelves with museum wax:
https://www.amazon.com/Quakehold-44111-13-Ounce-Museum-Wax/dp/B000FJQQHC

Only downside in my experience is that it can sorta melt over time and ooze out from beneath. Probably only on hot days.

Alien tape also works pretty well:
https://www.amazon.com/Double-Multipurpose-Removable-Adhesive-Transparent/dp/B09PWTVGPW

Also effective for cat-proofing (which is way more common than earthquakes).

What you want are fiddle rails, like are used on yachts. DIY and exceedingly fancy options available.

Double-sided tape is cheap and effective. Cut off 1"-2" strips and place at the bottom of everything on the shelves.

If you want to keep the finish of the surface(s) pretty neat, I like gaffer tape, followed by a layer of Velcro hook-and-loop fasteners. The Gaffer tape will come off neatly, when desired, and the Velcro hook-and-loop tape adheres nicely to the surface of the gaffer tape. I recommend the many types of Velcro hook-and-loop arrangements that come with a strong-ish adhesive on either side of the enclosing material.

Generally, even the cheapest stuff is perfectly adequate, IME.

Also, magnets will work. A pack of a few dozen or a hundred or so neodymium magnets can be had for under ten dollars, but should be handled with caution.

Or, good old double-sided tape. I use a few different kinds, but anything I’ve tried is more than capable of keeping those little birdies facing north.

In short, pretty much anything should work out fine for this scenario.

Pretty sure child labor laws don’t apply to your own children, so if you want to make your kids stand next to the shelf with your dishes on them during an earthquake, more power to you.