html - noscript 样式无效

标签 html css noscript

嘿,我正在制作一个 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

最佳答案

之后有 .noscript。 noscriptext 所以它显示在顶部。将 .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>

关于html - noscript 样式无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43575164/

相关文章:

javascript - 在 Ajax 中使用 noscript 标签

html - CSS 事件链接不起作用

javascript - 小 Jquery 问题

html - 如何在不使用边框间距和空行的情况下在带边框的表行之间添加空间

html - Marketo 日历邀请链接 CSS 样式

javascript - 检测 NoScript(不是标签,扩展名)

javascript - 为什么 Flask 中的 URL 重定向在控制台中有效,但现在在实际的 Web 应用程序中有效?

javascript - contenteditable 中无法访问的空列表项

jquery - 悬停时更改类的属性

javascript - 在禁用 JS 时使用 noscript 修改 html 元素和重定向页面?