Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
777 views
in Technique[技术] by (71.8m points)

mobile - Safari Responsive Design Mode CSS media query 'device' not applied

I have been using the Safari Responsive Design Mode while developing and debugging a responsive Website I am working on.

When setting to any mobile device (e.g. any iPhone or iPad), I was expecting a media query like this

@media screen and (max-device-width: 480px) {
    .disappear-on-device {
        display: none;
    }
}

to fire and style elements with the disappear-on-device class and on devices with width <= 480 accordingly, since the RDM can be specifically set to emulate an iPhones and iPads.

The styling is, however, not happening. Chrome responsive design mode seems to be handling this just fine. I have not been able to find anything related in the Safari preferences.

Am I missing something here? Is there a way to make Safari RDM act like an actual device?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

device-width, along with its siblings, min-device-width and max-device width have been deprecated and removed from the standards.

You should just use width, min-width, and max-width, which are calculated based on the size of the viewport. On most mobile devices, width, min-width, and max-width end up yielding the same net result as device-width, min-device-width, and max-device-width.

Here's information on the deprecation of device-width. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/device-width

Here's the new spec, which no longer includes device-width. https://www.w3.org/TR/mediaqueries-4/#width


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...