【问题标题】:Responsive design - Standard Breakpoint/Media queries for smartphone and tablet响应式设计 - 智能手机和平板电脑的标准断点/媒体查询
【发布时间】:2013-11-30 23:18:19
【问题描述】:

为响应式设计编写代码时,智能手机和平板电脑的标准宽度是多少。我查看了不同的网站,但似乎没有找到任何标准宽度的好模板。在编写响应式设计时,你们通常对断点/媒体查询做什么?

如果有人有平板电脑/智能手机等不同结果的好模板,请分享!谢谢!

【问题讨论】:

  • 避免设备驱动的断点;让内容和设计决定断点。
  • 我非常同意@skube。如this文章引用Instead of being concerned with device breakpoints the best practice is to design for your smallest viewport first. As you expand that view there will come a point at which the design looks terrible. This is where you add a break point.

标签: responsive-design


【解决方案1】:

有两种方式来思考您的 CSS 媒体查询。

第一个是“桌面优先”。这意味着您的基础 CSS 将针对大屏幕,然后您的媒体查询将覆盖您的类以适应较小的类。你的 CSS 可以是这样的:

/* Large screens ----------- */
/*some CSS*/

/* Desktops and laptops ----------- */
@media only screen and (max-width : 1824px) {...}

/* iPads (landscape) ----------- */
@media only screen and (max-width : 1224px) {...}

/* iPads (portrait) ----------- */
@media only screen and (max-width : 1024px) {...}

/* Smartphones (landscape) ----------- */
@media only screen and (max-width : 768px) {...}

/* Big smartphones (portrait) (ie: Galaxy 3 has 360)*/
@media only screen and (max-width : 640px) {...}

/* Smartphones (portrait) (ie: Galaxy 1) */
@media only screen and (max-width : 321px) {...}

第二种方法是“移动优先”。这意味着您的基本 CSS 将针对像 iPhone 4 这样的小屏幕。然后您的媒体查询将覆盖您的类以适应更大的屏幕。这是和示例:

/* Smartphones (portrait) ----------- */

/* Ipad2 (portrait) ----------- */
@media only screen and (min-width : 768px){...}

/* Ipad2 (paysage) ----------- */
@media only screen and (min-width : 1024px){...}

/* Ordi (Petit) ----------- */
@media only screen and (min-width : 1224px){...}

/* Desktops and laptops ----------- */
@media only screen and (min-width : 1824px){...}

如果您真的想深入了解细节并利用 Retina 显示屏,您将不得不玩弄像素比率。看看这个过度杀伤的 css 样式表:media-queries-boilerplate.css。使用视网膜显示器的好处之一是为客户提供更高质量的图像。缺点是它需要更多带宽并使网站变慢。

希望对你有所帮助。

【讨论】:

    【解决方案2】:

    在编写响应式设计元素时,我总是使用百分比 - 避免使用设备驱动的断点,正如 Skube 在他们对您的问题的评论中所说的那样。

    【讨论】:

    • 使用百分比很好,但大多数时候您需要设置最小值和最大值。创建一个在 iPhone 上看起来和在 1920x1080 显示器上看起来一样棒的网站是相当困难的。高级 CSS 样式表将使用带断点的百分比来实现真正的自适应布局。
    猜你喜欢
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 2014-03-27
    • 1970-01-01
    • 2016-08-30
    相关资源
    最近更新 更多