How to detect device to change the display of body?

Is possible to check the screen device to change the way of display the application ?

for example: I draw this paint to understand my idea (if possible using html or css)

As you see,

  • In case I used mobile browser to view my app it will display normal
  • But if I used PC/Laptop browser, the application will display in the center of screen (with out fit as screen)