R
R
Roman2019-09-28 14:08:19
Browsers
Roman, 2019-09-28 14:08:19

How to reliably distinguish on the client side from a mobile phone they are watching a site or from a desktop?

I want to set the font size in CSS, depending on whether they are watching from a mobile phone or from a laptop.
To navigate the screen resolution is such a thing, in this case.
What else can be done on the client side? (the backing is not supposed at all yet)
Is it possible somehow to resolve all this using pure CSS, without the help of JS?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2019-09-28
@xmoonlight

https://vanseodesign.com/css/media-queries/

N
Nikolai Shkrylev, 2019-09-29
@snnwolf

Try something like this hgoebl.github.io/mobile-detect.js

A
Anton, 2019-10-08
@anton99zel

Is the user agent that defines Android / iPhone not suitable?
www.useragentstring.com/pages/useragentstring.php

<?php
$iPod    = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
if( $iPod || $iPhone || $iPad ){
    echo "ios";
}else if($Android){
    echo "android";
}

Although, so-so solution.
I love media queries, em fonts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question