2017-04-23 69 views
0

嘿即時通訊製作一個html文件,我想要它,這樣當有人訪問該頁面並且有noscript啓用,它會使整個頁面變黑並顯示白色文本說「啓用JavaScript」 這裏是我的代碼:noscript風格沒有工作

<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

回答

2

您在. noscriptext之後有.noscript,所以它顯示在最上面。在.noscriptext之前輸入.noscript或在.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>