dtr32221 2013-10-23 05:02
浏览 33
已采纳

在移动中查看桌面站点(使用的框架较少)

I have used less framework for my site. For mobile screen resolution, a button called 'View Full Site' has been provided. When tapped, the desktop version of the site needs to be displayed. In short, the media query should be automatically changed to default. But I have no idea about how to do it. I know it would have been easy if I would have simply made 2 separate versions - one for mobile and one for desktop. But I would like to know a way to get the desktop version using less framework.

  • 写回答

1条回答 默认 最新

  • dongwei7048 2013-10-23 05:16
    关注

    One way to solve this is to set or remove a class on your <html> or <body> tag based on the user choice.

    For example, by default you could have

    <html class="responsive">
    

    Then, in your media query, prefix everything with this class

    @media (max-width: 767px) {
        // using LESS syntax here, otherwise, prefix each selector with .responsive
        .responsive {
            // all your CSS for small screens
        }
    }
    

    You could then set a cookie or some other form of persisted value for the user preference based on hitting the View full site button. Detect this value and use it to remove the responsive class from the document element, eg (in <head>)

    <script>
        if (full_site_requested) {
            document.documentElement.className = document.documentElement.className.replace('responsive', '');
        }
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址