【问题标题】:noscript style no workingnoscript 风格没有工作
【发布时间】:2017-04-23 18:52:16
【问题描述】:

嘿,我正在制作一个 html 文档,我想拥有它,这样当有人访问该页面并启用 noscript 时,它会使整个页面变黑并显示白色文本,上面写着“启用 JavaScript” 这是我的代码:

<noscript>
<style>
.noscript{
   width: 4000px;
   height: 4000px;
   position: fixed;
   top: 50%;
   left: 60%;
  transform: translate(-50%, -50%);
   background: black;
}
.noscriptext{
width: 400px;
   height: 100px;
   position: fixed;
   top: 40%;
   left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; font-size: 100%;
  color: white;
}

</style>

<div class="noscriptext"><h1>to use this you must enable javascript</h1></div>
</noscript>

<div class="noscript">&nbsp;</div>

但它不起作用请帮忙? 我试过这个: Body styling for a noscript tag? 但什么也没有。 图片:http://imgur.com/a/KRqXS

【问题讨论】:

    标签: html css noscript


    【解决方案1】:

    . noscriptext 后面有 .noscript,所以它显示在顶部。将.noscript 放在.noscriptext 之前或在.noscriptext 上使用z-index

    但是你可以简化一下,我会用这个来代替。

    <noscript>
    <style>
    .noscriptext {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: black;
      color: white;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    </style>
    <div class="noscriptext"><h1>to use this you must enable javascript</h1></div>
    </noscript>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-18
      • 1970-01-01
      • 2013-07-11
      • 2015-06-11
      • 2023-03-28
      • 2011-03-20
      • 2023-02-15
      • 2011-05-30
      相关资源
      最近更新 更多