首页 文章

CSS3背景渐变无法验证,有人可以告诉我为什么?内部代码示例

提问于
浏览
4

有人能告诉我为什么以下的CSS没有验证?我一直在努力研究这个,没有运气 . 我读过的所有文档都说这是为什么在css3中做渐变的正确方法 .

#header {
  color: white;
  font-size: 12px;
  font-family: Helvetica, Verdana, Arial, sans-serif;
  background: black;
  background: -moz-linear-gradient(top,  rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0)));
  background: -webkit-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
  background: -o-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
  background: -ms-linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
  background: linear-gradient(top,  rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);
  width: 100%;
  height: 35px;
  margin-top: 0px;
  margin-left: auto;
  margin-right: auto;
  padding: 10px;
  position: fixed;
  top: 0px;
  z-index: 1000;
}

这些是我得到的验证错误:

TextArea的W3C CSS Validator结果(CSS级别3)抱歉!我们发现了以下错误(6)URI:TextArea 6 #header Value Error:background-color -moz-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0, 0)100%)不是背景颜色值:-moz-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0)100%)7# Headers 值错误:background-color -webkit-gradient(线性,左上,左下,颜色停止(0%,rgba(0,0,0,0.65)),颜色停止(100%,rgba(0, 0,0,0)))不是背景颜色值:-webkit-gradient(线性,左上,左下,颜色停止(0%,rgba(0,0,0,0.65)),颜色 - 停止(100%,rgba(0,0,0,0)))8 #header值错误:background-color -webkit-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba( 0,0,0,0)100%)不是背景颜色值:-webkit-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0) )100%)9 #header Value Error:background-color -o-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0)100%)不是背景颜色值:-o-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0)100%)10 #header Va lue错误:background-color -ms-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0)100%)不是背景颜色值: - ms-linear-gradient(top,rgba(0,0,0,0.65)0%,rgba(0,0,0,0)100%)11 #header Value Error:background-color linear-gradient(top,rgba (0,0,0,0.65)0%,rgba(0,0,0,0)100%)不是背景颜色值:线性渐变(顶部,rgba(0,0,0,0.65)0 %,rgba(0,0,0,0)100%)

3 回答

  • 2

    这是一个副本:CSS background gradient validation

    一个很好的解释是:

    对于现代网页设计/开发中的CSS3,“有效”是一个非常流畅的术语 . 如果您尝试在W3C的CSS3 Validator中验证“this”代码,它将显示一堆解析错误 . 这是由于目前CSS3实现的性质,主要是因为创建CSS3渐变所需的供应商前缀 . 现在另一方面,根据浏览器供应商的说法,我们使用了正确的“有效”语法来实现这些渐变 . 事实上W3C尚未最终确定CSS3规范意味着在此之前我们将无法得到关于CSS3有效或无效的具体答案 . 我们现在所能做的就是遵循渐进增强技术,并关注浏览器供应商的方向和正确实现CSS3 .

    http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-understanding-css3-gradients/comment-page-1/#comment-243334

  • 0

    供应商特定扩展do not validate . 此外,您可能需要更改W3C验证服务选项以更改CSS配置文件级别,如this link所示 .

    无论如何,我不担心我的CSS3声明没有验证,因为验证只是一个指导你纠正可能的代码错误 .

  • 0

    确保为“配置文件”设置了正确的选项 . 它应该是css级别3.而验证器并不真正支持供应商特定的css .

相关问题