首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

学习小知识

学习编程是非常辛苦的过程,有时一些语言中的小知识却可以解决苦恼你半天的问题,今天分享的是@media screen针对不同移动设备-响应式设计

概念:

device-pixel-ratio:定义输入设备屏幕的可视宽度与可见高度比率。

device-width:输入设备屏幕的可视宽度。

orientation :屏幕横竖屏定向。landscape 是横向,portrait 是纵向【ipad 相反】

/* iPhone 4 ———– */

@media

only screen and (-webkit-min-device-pixel-ratio : 1.5),

only screen and (min-device-pixel-ratio : 1.5) {

/* Styles */

}

/* iPads (portrait) ———– */

@media only screen

and (min-device-width : 768px)

and (max-device-width : 1024px)

and (orientation : portrait) {

/* Styles */

}

/* Smartphones (portrait and landscape) ———– */

@media only screen

and (min-device-width : 320px)

and (max-device-width : 480px) {

/* Styles */

}

/* Smartphones (landscape) ———– */

@media only screen

and (min-width : 321px) {

/* Styles */

}

/* Smartphones (portrait) ———– */

@media only screen

and (max-width : 320px) {

/* Styles */

}

/* iPads (portrait and landscape) ———– */

@media only screen

and (min-device-width : 768px)

and (max-device-width : 1024px) {

/* Styles */

}

/* iPads (landscape) ———– */

@media only screen

and (min-device-width : 768px)

and (max-device-width : 1024px)

and (orientation : landscape) {

/* Styles */

}

/* iPads (portrait) ———– */

@media only screen

and (min-device-width : 768px)

and (max-device-width : 1024px)

and (orientation : portrait) {

/* Styles */

}

/* Desktops and laptops ———– */

@media only screen

and (min-width : 1224px) {

/* Styles */

}

/* Large screens ———– */

@media only screen

and (min-width : 1824px) {

/* Styles */

}

/* iPhone 4 ———– */

@media

only screen and (-webkit-min-device-pixel-ratio : 1.5),

only screen and (min-device-pixel-ratio : 1.5) {

/* Styles */

}

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180612G10VOD00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券