gpt4 book ai didi

responsive-design - 响应式设计 - 智能手机和平板电脑的标准断点/媒体查询

转载 作者:行者123 更新时间:2023-12-04 01:38:06 24 4
gpt4 key购买 nike

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

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

最佳答案

有两种方式来思考你的 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){...}

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

我希望这对你有帮助。

关于responsive-design - 响应式设计 - 智能手机和平板电脑的标准断点/媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20301680/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com