Javascript querye.js匹配了两个媒体查询
这是我的两个媒体问题Javascript querye.js匹配了两个媒体查询,javascript,media-queries,match,enquire.js,Javascript,Media Queries,Match,Enquire.js,这是我的两个媒体问题 @media screen and (min-width:1240px) and (min-height:800px) @media screen and (min-width:1400px) and (min-height:900px) enquire .register("screen and (min-width:1240px) and (min-height:800px)", { match: function() { console.l
@media screen and (min-width:1240px) and (min-height:800px)
@media screen and (min-width:1400px) and (min-height:900px)
enquire
.register("screen and (min-width:1240px) and (min-height:800px)", {
match: function() {
console.log('1240px');
},
unmatch: function() {
console.log('<1240px');
},
})
.register("screen and (min-width:1400px) and (min-height:900px)", {
match: function() {
console.log('1400px');
},
unmatch: function() {
console.log('<1400px');
});
我使用Enquire.js来匹配我的媒体查询
@media screen and (min-width:1240px) and (min-height:800px)
@media screen and (min-width:1400px) and (min-height:900px)
enquire
.register("screen and (min-width:1240px) and (min-height:800px)", {
match: function() {
console.log('1240px');
},
unmatch: function() {
console.log('<1240px');
},
})
.register("screen and (min-width:1400px) and (min-height:900px)", {
match: function() {
console.log('1400px');
},
unmatch: function() {
console.log('<1400px');
});
查询
.寄存器(“屏幕和(最小宽度:1240px)和(最小高度:800px)”{
匹配:函数(){
控制台日志('1240px');
},
取消匹配:函数(){
console.log('如果您希望媒体查询相互排斥(即无重叠),则向其添加最大宽度条件。例如,屏幕和(最小宽度:1240px)和(最小高度:800px)和(最大宽度:1400px)和(最大高度:900px)
我试过了,但它不起作用。还有其他方法吗?因为在没有Inquire.js的情况下,媒体查询只需最小宽度和最小高度就可以正常工作,它总是会转到正确的位置。但在Inquire.js中,它的工作方式不一样……如果我没有为(最小宽度:1400px)和(最小高度:900px)设置不匹配函数的话
,它不会触发(最小宽度:1240px)和(最小高度:800px)
我想我没有很好地表达它,所以主要问题是inquire.js在从(最小宽度:1400px)和(最小高度:900px)向下调整大小时与屏幕和(最小宽度:1240px)和(最小高度:800px)不匹配
哪种媒体查询匹配。你能拿出提琴/code笔来演示问题吗?没有测试用例很难推理。干杯