简体   繁体   English

自适应设计:如何在不同的屏幕分辨率下修改CSS网格大小?

[英]Responsive Design: how to modify css grid sizes at different screen resolutions?

Currently I am using something like this to modify grid sizes when a browser hits a certain width (break point), for example: 当前,当浏览器达到某个宽度(断点)时,我正在使用类似的方法来修改网格大小,例如:

var width = jQuery(window).width();

if (width <= 480) {

    // Resize from grid_10 to grid_16 (Home, Featured, News)
    jQuery('.featured, .featured-page, .news-page, #footer-pagination').removeClass('grid_10').addClass('grid_16');
}

Is there a better approach to accomplish this? 是否有更好的方法来实现这一目标? One of the issues I am experiencing is a slight "hickup" after the page initially loads as I can see the grid resizing from grid_10 to grid_16? 我遇到的问题之一是页面最初加载后出现了轻微的“堆积”,因为我可以看到网格从grid_10调整为grid_16? Ideally I would like to eliminate this hickup. 理想情况下,我想消除此问题。

App.net的家伙几天前发布了一个有趣的解决方案,其中他们为不同的断点定义了不同的网格单元类,并使用媒体查询在它们之间切换: https : //gist.github.com/3362608

Have a look at css media queries here: http://css-tricks.com/css-media-queries/ 在这里查看CSS媒体查询: http : //css-tricks.com/css-media-queries/

They are fast and work on mobile phones as well. 它们速度很快,也可以在手机上工作。

There are specific grid-frameworks for Responsive Design. 对于响应式设计,有特定的网格框架。 I prefer Susy in use with Compass: http://susy.oddbird.net and http://compass-style.org 我更喜欢Susy与Compass一起使用: http : //susy.oddbird.nethttp://compass-style.org

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

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