Javascript JS window.matchMedia右语法

Javascript JS window.matchMedia右语法,javascript,matchmedia,Javascript,Matchmedia,我有一个问题,如何写一个正确的句子来反映屏幕大小的完整css@media查询和JS窗口的屏幕方向(示例如下)。matchMedia,我能找到的只是大小(无方向)和方向(无大小)的单独示例。此CSS示例的正确语法是什么: @media only screen and (min-width: 483px) and (orientation: landscape) {} 在此代码中: if (window.matchMedia("(orientation: portrait)").matches)

我有一个问题,如何写一个正确的句子来反映屏幕大小的完整css@media查询和JS
窗口的屏幕方向(示例如下)。matchMedia
,我能找到的只是大小(无方向)和方向(无大小)的单独示例。此CSS示例的正确语法是什么:

 @media only screen and (min-width: 483px) and (orientation: landscape) {}
在此代码中:

if (window.matchMedia("(orientation: portrait)").matches) {
   // how to add a screen size to this exact code?
}

它与CSS相同。这就是重点

window.matchMedia("only screen and (min-width: 483px) and (orientation: landscape)").matches

它与CSS相同。这就是重点

window.matchMedia("only screen and (min-width: 483px) and (orientation: landscape)").matches

它是否必须有“仅屏幕和”?我没有在任何文档或示例@quentina中播撒这一“部分”,这里没有什么后续内容,我如何添加一个
eventListner
来更改屏幕方向?(我是JS新手,所以我需要一点帮助)它是否必须有“只有屏幕和”?,我没有在任何文档或示例@quentina中播撒这一“部分”,这里没有后续内容,我如何添加一个
eventListner
来更改屏幕方向?(我是JS新手,所以我需要一些帮助)