【问题标题】:jquery mobile responsive gridsjquery 移动响应式网格
【发布时间】:2014-08-26 07:57:30
【问题描述】:

我正在构建一个 jquery 移动应用程序,我想实现响应式三列设计。侧栏只是像 instagram 这样的填充物。侧栏在小屏幕上变为最小宽度,在大屏幕上为 10%,它们可以占据 25% 的空间。

风格:

.min-width-320px .leftcol, .max-width-480px .leftcol {
        width:10%;
}

.min-width-480px .leftcol, .max-width-768px .leftcol {
        width:25%;
}

.leftcol { 
    position:relative;
    top:-10px;
    left:-10px;
    float:left;
    width:220px;  /* for IE5/WIN */
    voice-family: "\"}\"";
    voice-family:inherit;
    margin:0 0 -10px 0;
    padding:10px;
    background:#e9e9e9;
    z-index:100;
    border-right:1px solid #bebebe;
    height:100%;
}

.min-width-320px .rightcol, .max-width-480px .rightcol {
        width:10%;
}

.min-width-480px .rightcol, .max-width-768px .rightcol {
        width:25%;
}

.rightcol {
    position:relative;
    top:-10px;
    right:-10px;
    float:right;
    voice-family: "\"}\"";
    voice-family:inherit;
    width:220px; /* actual value */
    margin:0 0 -10px 0;
    padding:10px;
    background:#e9e9e9;
    z-index:99;
    border-left:1px solid #bebebe;
    height:100%;
    }

#centercol {
    position:relative;
    padding:0 240px;
    background:#dadbdc;
    }

在正文中的主要内容 div

    <div id="leftcol" class="leftcol"><!-- begin leftcol -->
            &nbsp;
        </div><!-- end leftcol -->

        <div id="rightcol" class="rightcol"><!-- begin rightcol -->
            &nbsp;</p>          

        </div><!-- end righttcol -->

        <div id="centercol"><!-- begin centercol -->
            This is center col
        </div><!-- end centercol -->

但是当我在小分辨率下尝试时,它不会调整内容的大小。

【问题讨论】:

    标签: jquery css jquery-mobile media-queries


    【解决方案1】:

    使用带有媒体查询的网格解决了这个问题

    代码在这里。

    <style type="text/css">
    /*
    When the screen is 30em and below, the column b is stacked below 
    column a and column c is hidden.
    */
    @media all and (max-width: 30em) {
    
    .home-breakpoint .ui-block-a {
        display: none;
     }
     .home-breakpoint .ui-block-b {
        width: 100%;
        float:none; 
    
      }
    
     .home-breakpoint .ui-block-c {
        display: none;
      }
    }
    
    
    /*
    When the screen is above 30em and below 48em, columns a and b 
    are displayed beside each other,  column c is hidden.
    */
    @media all and (min-width: 30.1em) and (max-width:48em) {
    .home-breakpoint .ui-block-a {
        width: 20%;float: left;
    background-color:#e9e9e9;
    
    }
    
    .home-breakpoint .ui-block-b {
        width: 60%;float: left;
    
    }
    .home-breakpoint .ui-block-c {
        width: 20%;float: left;
    background-color:#e9e9e9;
    
    }
    }
    
    
    /*
    When the screen is above 48em all 3 columns are shown 
    beside each other.
    */
    
    @media all and (min-width: 48.1em) {
    .home-breakpoint .ui-block-a {
        width: 20%;float: left;
    background-color:#e9e9e9;
    
    }
    
    .home-breakpoint .ui-block-b {
        width: 60%;float: left;
    
    }
    .home-breakpoint .ui-block-c {
        width: 20%;float: left;
    background-color:#e9e9e9;
    
    }
    }
    </style>
    

    在 jquery 移动页面的内容部分

    <div class="ui-grid-b home-breakpoint">
        <div class="ui-block-a" > 
           &nbsp;
        </div>
        <div class="ui-block-b">                            
          <p>This is the middle column.</p>
        </div>
       <div class="ui-block-c" >                            
          &nbsp;
       </div>  
    </div>
    

    【讨论】:

      猜你喜欢
      • 2018-10-17
      • 2014-06-14
      • 2013-06-04
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-28
      相关资源
      最近更新 更多