我使用下面的代碼在移動設備(智能手機或平板電腦)處於縱向模式時顯示消息。這工作正常!用按鈕刪除整個會話的消息?
但是,我需要的代碼是,當用戶單擊X按鈕時,只要在該會話中訪問網站的任何頁面,就不會再出現該消息。
但是,如果網站已關閉,在下次訪問時,當以縱向模式查看網站時,該消息應該再次出現。
這怎麼辦?
html,
body {
width: 100%;
height: 200%;
}
#warning-message {
display: none;
}
@media only screen and (orientation:portrait) {
#warning-message {
display: block;
}
}
@media only screen and (orientation:landscape) {
#warning-message {
display: none;
}
}
#landscape-button {
background-color: #2A3847;
color: #ffffff;
border-radius: 0px;
border: 1px solid white;
padding: 10px 10px 10px 10px;
float: right;
margin-top: -25px;
margin-right: -15px;
font-size: 1.3em;
}
Please open in "full page" mode and scale your window to a portrait size to see the message appear.<br><br>
<div id="warning-message" style="position:fixed; margin: 0 auto 0 auto; z-index: 99999999; background-color: #2A3847; width: 90vw; min-height: 90vh; text-align:center; padding:25px 15px 35px 15px; right: 0;
left: 0;
margin-right: auto;
margin-left: auto;">
<button type="button" id="landscape-button">X</button>
<p style="font-size: 1.3em; color: #ffffff; positie:absolute; text-align:center;"><span style="margin: 0 0 0 25px; text-align:center; font-size: 2em; letter-spacing: -0.04em;">please rotate your screen</span><br><br>This website is best viewed in landscape mode. So please, rotate your mobile device, and if activated also disable
your screen rotation lock. If you prefer to remain in portrait mode, ignore this message and close it at the "x".</p>
</div>
你應該去的cookie。 –
我會怎麼做,@Nirav Joshi。如果用戶關閉了cookies,該怎麼辦? – Eddy
比你可以使用會話。 –