Home > Web Front-end > CSS Tutorial > How to Customize CSS for Mobile Devices: Is @media handheld Still Relevant?

How to Customize CSS for Mobile Devices: Is @media handheld Still Relevant?

DDD
Release: 2024-11-26 17:15:10
Original
320 people have browsed it

How to Customize CSS for Mobile Devices: Is @media handheld Still Relevant?

Mobile Device CSS Customization:

Many web developers encounter challenges when customizing CSS for handheld devices such as iPhones and Android phones. The conventional method of using @media handheld does not work uniformly across devices.

Solution: Use @media Queries

To overcome this limitation, employ @media queries. This CSS technique allows you to target specific device characteristics, including screen size:

<link rel="stylesheet" href="iphone.css" media="only screen and (max-device-width:480px)" />
Copy after login

This query specifically targets devices with a maximum screen width of 480px, which commonly covers iPhones.

iPhone as an Exception

iPhone browsers, powered by Safari, do not honor @media handheld due to their advanced CSS rendering capabilities. This may vary with older iOS versions.

Targeting Devices with Higher Resolutions

Some newer mobile devices, such as the Droid X, feature higher resolutions. To accommodate these devices, use more specific @media queries that incorporate screen resolution:

<link rel="stylesheet" href="shetland.css" media="screen and (max-device-width: 480px) and (resolution: 163dpi)" />
Copy after login

Further Reading:

  • [A List Apart: Media Queries for Responsive Web Design](https://alistapart.com/article/responsive-web-design)
  • [W3C Candidate Recommendation for Media Queries](https://www.w3.org/TR/css3-mediaqueries/)

The above is the detailed content of How to Customize CSS for Mobile Devices: Is @media handheld Still Relevant?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template