gpt4 book ai didi

javascript - 仅在桌面上显示网页

转载 作者:行者123 更新时间:2023-12-01 09:41:34 25 4
gpt4 key购买 nike

我使用 HTML、CSS、JS (Paper.js) 创建了一个网页
但我希望我的网页仅在桌面站点中打开时显示
如果它在任何智能手机中打开,则消息必须显示为 在桌面打开 无需加载任何其他内容
因为在触摸屏设备中所有功能都不能正常工作

链接到我的网页是 -

https://sachinverma53121.github.io/Keypress-Sounds/key-sounds.html

最佳答案

如果页面小于一定宽度 可以使用 JS 不显示 div/tag

这样的事情可能会做:

<p id="demo">This only shows when the window is more than 500.</p>
<p id="message" style="display: none;">Please use this on a desktop.</p>



<script>
if (window.innerWidth < 500){
document.getElementById("demo").style.display = "none";
document.getElementById("message").style.display = "block";
}
</script>

你也可以使用 CSS
<style>
#message {
display: none;
}

@media (max-width: 500px){
#demo {
display: none;
}

#message {
display: block;
}
}
</style>

<p id="demo">This only shows when the window is more than 500.</p>
<p id="message">Please use this on a desktop.</p>

关于javascript - 仅在桌面上显示网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59851694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com