【问题标题】:Simple code not working in chrome简单的代码在 chrome 中不起作用
【发布时间】:2014-03-20 14:27:59
【问题描述】:

这在谷歌浏览器中不起作用。知道为什么吗?

<html>
  <head>
    <style type="css/text">
      #wrapper{display:none}
    </style>
  </head>
  <body>
    <div id="wrapper" >
      This is a test this is a test
    </div>
  </body>
</html>

【问题讨论】:

  • 你的意思是在其他浏览器中这段代码可以工作?奇怪...

标签: html css google-chrome browser


【解决方案1】:

css/text 应该是text/css

<style type="text/css">

然而,在 HTML5 中,style 元素的 type 如果未指定,则默认为“text/css”,因此根据您支持的浏览器,您可以完全放弃它。

【讨论】:

  • @Mr.Alien 当您编辑评论时,我正在编辑答案。只需先检查规格以确保我没有编造! :)
  • Aay ayy 确认,完全有效 :)
【解决方案2】:

样式标签应该是:

<style type="text/css">

或者更好的是,删除它!

<style>

【讨论】:

    【解决方案3】:

    你应该改变

    &lt;style type="css/text"&gt;&lt;style type="text/css"&gt;

    【讨论】:

      【解决方案4】:

      它是text/css,而不是相反。 :P

      【讨论】:

        【解决方案5】:

        删除此属性:

        type="css/text"
        

        【讨论】:

          【解决方案6】:

          以下代码将起作用。

              <style type="text/css">
                  #wrapper{display:none}
                  </style>
          
          </head>
          <body>
              <div id="wrapper" >
                  This is a test this is a test
              </div>
          </body>
          

          【讨论】:

          • 天哪,这么多重复,你们读过投票的答案吗?还是您提供的答案与其他答案不同?
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-04-05
          • 1970-01-01
          • 2023-03-22
          • 1970-01-01
          • 2016-12-21
          • 1970-01-01
          相关资源
          最近更新 更多