13700000000
  • 当前位置:
  • 首页 > 
  • 通过JavaScript代码实现在不同设备上显示不同的内容

通过JavaScript代码实现在不同设备上显示不同的内容

发布时间:2023年12月02日 20:05:12 作者:piikee  浏览数:123
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Example</title>
    <style>
        #desktop-content {
            display: block;
        }

        #mobile-content {
            display: none;
        }

        @media only screen and (max-width: 600px) {
            #desktop-content {
                display: none;
            }

            #mobile-content {
                display: block;
            }
        }
    </style>
</head>
<body>

<div id="desktop-content">
    <h1>This is Desktop Content</h1>
    <p>This content is visible on desktop devices.</p>
</div>

<div id="mobile-content">
    <h1>This is Mobile Content</h1>
    <p>This content is visible on mobile devices with a width of 600 pixels or less.</p>
</div>

<script>
    // JavaScript for additional interactivity (if needed)
</script>

</body>
</html>


关键词: