Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

website mobile compatibility

How to make website that should compatibility with desktop browser as well as mobile browser?

like image 400
Aswan Avatar asked Apr 20 '26 02:04

Aswan


1 Answers

There's the trick with alternative CSS files for desktop and mobile. Implemented in HTML header thusly:

<head>
<meta name="viewport" content="width=320" />
<link rel="stylesheet" href="mobile.css" type="text/css" media="only screen and (max-device-width: 480px)"/>
<link rel="stylesheet" href="desktop.css" type="text/css" media="screen and (min-device-width: 481px)"/>
<link rel="stylesheet" href="mobile.css" type="text/css" media="handheld"/>
<!--[if IE]>
<link rel="stylesheet" href="desktop.css" media="screen" type="text/css" />
<![endif]-->
</head>

Then if you need alternative content for mobile and desktop, feel free to make parts of HTML visible on desktop and hidden on mobile, or vice versa.

Tried on iPhone and Android. Note that simply specifying "media="handheld"" in the ref tag or in the CSS file does not do the trick; iPhone does not consider itself a handheld.

like image 123
Seva Alekseyev Avatar answered Apr 21 '26 16:04

Seva Alekseyev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!