大佬教程收集整理的这篇文章主要介绍了css – Bootstrap 4 – 媒体查询方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Bootstrap是一个节省生命,清洁,简单和< 3一切. 我需要一些媒体查询的建议 在Bootstrap 4中,有2个选项(首先是移动设备或第一个是桌面设备)**指的是最小宽度和最大宽度 经过一些实验,我首先喜欢使用桌面而不是代码移动
// Extra small devices (porTrait phones,less than ???pX) // No media query since this is the default in Bootstrap // small devices (landscape phones,34em and up) @media (min-width: 34em) { ... } // Medium devices (tablets,48em and up) @media (min-width: 48em) { ... } // Large devices (desktops,62em and up) @media (min-width: 62em) { ... } // Extra large devices (large desktops,75em and up) @media (min-width: 75em) { ... }
我认为这将首先关注移动,而不是升级到桌面
这个从桌面到移动
// Extra small devices (porTrait phones,less than 34em) @media (max-width: 33.9em) { ... } // small devices (landscape phones,less than 48em) @media (max-width: 47.9em) { ... } // Medium devices (tablets,less than 62em) @media (max-width: 61.9em) { ... } // Large devices (desktops,less than 75em) @media (max-width: 74.9em) { ... } // Extra large devices (large desktops) // No media query since the extra-large breakpoint has no upper bound on its width
但我发现桌面首先会覆盖小型媒体查询
@media (max-width: 74.9em) { body {BACkground-color: pink;} } @media (max-width: 61.9em) { body {BACkground-color: blue;} } @media (max-width: 47.9em) { body {BACkground-color: green;} } @media (max-width: 33.9em) { body {BACkground-color: red;} } body { BACkground-color: skyBlue; }
随着我缩小它,它只显示天蓝色……
但如果我用另一种方式可以吗?
/* global */ body { BACkground-color: skyBlue; } /* less than 75 */ @media (max-width: 74.9em) { body {BACkground-color: pink;} } /* less than 62 */ @media (max-width: 61.9em) { body {BACkground-color: blue;} } /* less than 48 */ @media (max-width: 47.9em) { body {BACkground-color: green;} } /* less than 34 */ @media (max-width: 33.9em) { body {BACkground-color: red;} }
这意味着,我将首先将大屏幕编码为小型设备?…
这是完成此操作的最佳方式.从大到小.
为什么?
因为所有小于34.00 em的设备也小于75.00 em,所以总是最后一个会覆盖一切.现在当你颠倒这个顺序时,它对你来说会很好.每个设备都将在其中一个查询中停止,并且不会更进一步.
/* MORE THAN 75 */ body { BACkground-color: skyBlue; } /* LESS THAN 75 */ @media (max-width: 74.9em) { body {BACkground-color: pink;} } /* LESS THAN 62 */ @media (max-width: 61.9em) { body {BACkground-color: blue;} } /* LESS THAN 48 */ @media (max-width: 47.9em) { body {BACkground-color: green;} } /* LESS THAN 34 */ @media (max-width: 33.9em) { body {BACkground-color: red;} }
以上是大佬教程为你收集整理的css – Bootstrap 4 – 媒体查询方法全部内容,希望文章能够帮你解决css – Bootstrap 4 – 媒体查询方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。