导航
×
   ❮   
HTML CSS JavaScript PHP Go Sass W3C Colors ECMS

JS 参考手册

JS 参考手册(字母排序)

JavaScript

JS Arrays JS Boolean JS Classes JS Dates JS Error JS Global JS Iterators JS JSON JS Maps JS Math JS Numbers JS Objects JS Operators JS Assignment JS Arithmetic JS Comparison JS Logical Operators JS Bitwise Operators JS Misc Operators JS Precedence JS Promises JS RegExp Patterns JS RegExp Reference JS Sets JS Statements JS Strings JS Typed Arrays JS Typed Reference

Window

Window Object Window Console Window History Window Location Window Navigator Window Screen

HTML DOM

HTML Documents HTML Elements HTML Attributes HTML Collection HTML NodeList HTML DOMTokenList HTML Styles
alignContent alignItems alignSelf animation animationDelay animationDirection animationDuration animationFillMode animationIterationCount animationName animationTimingFunction animationPlayState background backgroundAttachment backgroundClip backgroundColor backgroundImage backgroundOrigin backgroundPosition backgroundRepeat backgroundSize backfaceVisibility border borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius borderBottomStyle borderBottomWidth borderCollapse borderColor borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth borderLeft borderLeftColor borderLeftStyle borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth borderSpacing borderStyle borderTop borderTopColor borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom boxShadow boxSizing captionSide caretColor clear clip color columnCount columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columns columnSpan columnWidth counterIncrement counterReset cssFloat cursor direction display emptyCells filter flex flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap font fontFamily fontSize fontStyle fontVariant fontWeight fontSizeAdjust height isolation justifyContent left letterSpacing lineHeight listStyle listStyleImage listStylePosition listStyleType margin marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth objectFit objectPosition opacity order orphans outline outlineColor outlineOffset outlineStyle outlineWidth overflow overflowX overflowY padding paddingBottom paddingLeft paddingRight paddingTop pageBreakAfter pageBreakBefore pageBreakInside perspective perspectiveOrigin position quotes resize right scrollBehavior tableLayout tabSize textAlign textAlignLast textDecoration textDecorationColor textDecorationLine textDecorationStyle textIndent textOverflow textShadow textTransform top transform transformOrigin transformStyle transition transitionProperty transitionDuration transitionTimingFunction transitionDelay unicodeBidi userSelect verticalAlign visibility width wordBreak wordSpacing wordWrap widows zIndex

HTML Events

HTML Events HTML Event Objects HTML Event Properties HTML Event Methods

Web APIs

API Canvas API Console API Fetch API Fullscreen API Geolocation API History API MediaQueryList API Storage API Validation API Web

HTML 对象

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <sub> <summary> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

MediaQueryList API


MediaQueryList 对象

MediaQueryList 对象 存储媒体查询信息。

MediaQueryList 对象window 对象 的一个属性。

可通过以下方式访问 MediaQueryList 对象:

window.matchMedia() 或直接 matchMedia():

示例

const mqlObj = window.matchMedia();
亲自试一试 »
const mqlObj = matchMedia();
亲自试一试 »

MediaQueryList 属性

属性 描述
matches 布尔值。
true表示文档与查询匹配,否则false
media 字符串。
媒体查询(列表)。

MediaQueryList 方法

方法 描述
addListener() 添加一个新的监听器函数,该函数会在媒体查询的评估结果发生变化时执行
removeListener() 从媒体查询列表中移除先前添加的监听器函数。如果指定的监听器不在列表中,则不执行任何操作。

媒体查询

matchMedia() 方法的媒体查询可以是 CSS @media 规则 的任何媒体特性,例如 min-height、min-width、orientation 等。

示例

matchMedia("(max-height: 480px)").matches);
matchMedia("(max-width: 640px)").matches);

媒体类型

媒体类型描述设备的总体类别。

描述
all 默认值。适用于所有媒体类型设备
print 用于打印机
screen 适用于电脑屏幕、平板电脑、智能手机等。

媒体特性

媒体特性用于根据设备的屏幕尺寸、方向和分辨率等功能应用样式。

媒体特性是可选的,每个媒体特性表达式都必须用括号括起来。

描述
any-hover 是否有任何可用的输入机制允许用户将鼠标悬停在元素上?
any-pointer 是否有任何可用的输入机制是指针设备?如果是,其精度如何?
aspect-ratio 视口宽度与高度之比
color 输出设备每个颜色分量的位数
color-gamut 用户代理和输出设备支持的颜色范围
color-index 设备可显示的颜色数量
device-posture 检测设备的当前姿态,即视口是处于平放状态还是折叠状态
display-mode 应用程序的显示模式:例如,全屏模式或画中画模式
dynamic-range 用户代理和输出设备支持的亮度、对比度和色深的组合
forced-colors 检测用户代理是否限制调色板
grid 设备是网格还是位图
height 视口高度
hover 主要输入机制是否允许用户将鼠标悬停在元素上?
inverted-colors 浏览器或底层操作系统是否反转了颜色?
monochrome 单色(灰度)设备上每个"颜色"的位数
orientation 视口方向(横向或纵向模式)
overflow-block 输出设备如何处理沿块轴溢出视口的内容
overflow-inline 沿内联轴溢出视口的内容是否可以滚动
pointer 主要输入机制是否为指点设备?如果是,其精度如何?
偏好配色方案 用户偏好浅色配色方案还是深色配色方案?
偏好对比度 用户偏好高对比度显示?
prefers-reduced-data 用户是否希望减少数据使用量?
prefers-reduced-motion 用户是否希望减少动态效果?
prefers-reduced-transparency 用户是否希望降低透明度?
resolution 输出设备的分辨率,使用 dpi 或 dpcm 单位
scan 输出设备的扫描过程
scripting 是否支持脚本(例如 JavaScript)?
shape 视口是圆形还是矩形?
update 输出设备能够以多快的速度改变内容的外观?
video-dynamic-range 用户代理和输出设备的视频平面所支持的亮度、对比度和色彩深度的组合。
width 视口宽度

Copyright ©2020-2026 freew3c.com All Rights Reserved 提供的内容仅用于学习和测试,不保证内容的正确性。