screen.orientation is used to detect the current orientation. Locking requires fullscreen and only works on Chrome Android.

Current orientation

-
-

CSS detection

Rotate the device to see the change