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
responsiveclass from the document element, eg (in<head>)<script> if (full_site_requested) { document.documentElement.className = document.documentElement.className.replace('responsive', ''); } </script>本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报