简体   繁体   English

如何覆盖Twitter Bootstrap 2中的响应功能?

[英]How to override responsive features in Twitter Bootstrap 2?

I have a site using twitter bootstrap and am using some of the responsive features. 我有一个使用twitter bootstrap的网站,并使用了一些响应功能。 It works fine on the desktop and the mobile devices. 它在桌面和移动设备上运行良好。 Shrinking my window on the desktop cause the responsive grid to kick in, and the responsive grid is served to the mobile device appropriately. 缩小我在桌面上的窗口会导致响应式网格启动,并且响应式网格会适当地提供给移动设备。

However, is it possible for an iPhone user to access the 'non-responsive' version? 但是,iPhone用户是否可以访问“无响应”版本? It's usually safe for iPhone and android phones to access the 'full' version of most sites, so I'd like to offer that as an option for the mobile users. iPhone和Android手机通常可以安全地访问大多数网站的“完整”版本,因此我想将其作为移动用户的选项提供。

Back before 'responsive' was the hottest thing, this was typically handled via client browser detection and the backend routed the clients to two completely different sites, pages, or themes to render the content, and there was usually some kind of link or button afforded to the user to allow them to visit the full-site instead. 在“响应”是最热门的事情之前,这通常是通过客户端浏览器检测来处理的,并且后端将客户端路由到两个完全不同的站点,页面或主题来呈现内容,并且通常提供某种类型的链接或按钮用户允许他们访问全站点。 I'm trying to replicate that usage pattern. 我正在尝试复制该使用模式。

If you don't want to reload your page after the change to the "desktop" version you could try to disable your repsonsive stylesheet(s). 如果您不想在更改为“桌面”版本后重新加载页面,则可以尝试禁用您的repsonsive样式表。 See: Removing or replacing a stylesheet (a <link>) with JavaScript/jQuery and https://stackoverflow.com/a/15824131/1596547 . 请参阅: 使用JavaScript / jQueryhttps://stackoverflow.com/a/15824131/1596547 删除或替换样式表(<link>) Also Removing the stylesheet seems to work. 还删除样式表似乎工作。

Some proof of concept with removing the responsive stylesheet: 删除响应式样式表的一些概念证明:

css : css

<link href="bootstrap-responsive.css" rel="stylesheet" id="responsivecss">

javascript : javascript

    var responsivecss = true;

    $('#switch').click(



    function ()
        {
            if(responsivecss)
            {
        $('#responsivecss').remove();
      $(this).text('Mobile version');           
              responsivecss = false;

            }
            else
            {
      $('head').append('<link href="bootstrap-responsive.css" rel="stylesheet" id="responsivecss">');
      $(this).text('Desktop version');
                responsivecss = true;
            }       



        }

    );

Try it: http://plnkr.co/LdOUquuYPMnOOd5UrBtZ 试试吧: http//plnkr.co/LdOUquuYPMnOOd5UrBtZ

Twitter's Bootstrap 3 Twitter的Bootstrap 3

TB3 don't have a separate responsive CSS file. TB3没有单独的响应式CSS文件。 To do the same you will have to create a css file without the responsive features (see: http://bassjobsen.weblogs.fm/compile-twitters-bootstrap-3-without-responsive-features/ ) an switch these files on click. 要做同样的事情,你将不得不创建一个没有响应功能的css文件(参见: http//bassjobsen.weblogs.fm/compile-twitters-bootstrap-3-without-responsive-features/ )切换这些文件点击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM