css - 错误的 css 媒体语法

标签 css media

这里有什么问题吗?

<link rel="stylesheet" href='index-02.css'
      media="screen and (min-width: 481px and max-width:959px)">

验证 this page 上的代码我收到一个错误:

Error: Bad value screen and (min-width: 481px and max-width:959px) for attribute media on element link: Expected whitespace or ) but saw a instead.

最佳答案

您的语法略有偏差。每个表达式都需要包含在括号中:

<link rel="stylesheet" href='index-02.css'
      media="screen and (min-width: 481px) and (max-width:959px)">

来自documentation :

Parentheses are required around expressions; failing to use them is an error.

关于css - 错误的 css 媒体语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39424271/

相关文章:

css - 将图像放在 div 的中心

jquery - Bootstrap 的导航栏下拉菜单无法在自定义断点下方正确打开

android - 在 Android 上的测试用例之外运行 ExtractDecodeEditEncodeMuxTest

c# - 使用rest api通过sas url上传到Azure媒体服务

html - 如果屏幕窄于 500px,想放入样式标签并告诉 h1 字体大小为 50 像素

javascript - 使用 Javascript append 构建列表

css - 使用 HTML/CSS 创建直线和圆的交点

android - 使用 Android MediaStore 管理媒体

html - 动态响应调整图像大小

javascript - jquery.width() 和 jquery.height 有时会出错