1

我在使用 jQuery mobile 和 CSS3 媒体查询创建响应式网格时遇到了困难。我确实有响应,但它并没有按照我想要的方式重新排列。这就是我所拥有的。

它是一个 2 行 x 5 列的网格。我试图把它变成一个 10 行的单列。这是我可以做到的,但我试图以我想要的方式获得订单。

所以看起来像这样

|A|B|C|D|E|

|A|B|C|D|E|

我试图让它在下面执行此操作(我想要它 AABBCCDDEE,但我只能管理它以 ABCDEABCDE 顺序下降......)


|一个|

|一个|

|B|

|B|

|C|

|C|

|D|

|D|

|电子|

|电子|

这是我的网格代码:

<div class="ui-grid-d my-breakpoint">
    <div class="ui-block-a">
        <input type="image" id="jog" src="images/jog.gif">
    </div>
    <div class="ui-block-b">
        <input type="image" id="rewfwd" src="images/rewfwdOff.gif">
    </div>
    <div class="ui-block-c">
        <input type="image" id="hand" src="images/handOff.gif">
    </div>
    <div class="ui-block-d">
        <input type="image" id="auto" src="images/autoOff.gif">
    </div>
    <div class="ui-block-e">
        <input type="image" id="off" src="images/offOff.gif">
    </div>
    <div class="ui-block-a">
        <a href="#jogPopup" data-rel="popup" data-role="button"  data-theme="a" data-icon="gear" data-position-to="header">Jog</a>
    </div>
    <div class="ui-block-b">
        <a href="#rewfwdPopup" data-rel="popup" data-role="button" data-theme="a" data-icon="gear" data-position-to="header" data-transition="slideup">R F</a>
    </div>
    <div class="ui-block-c">
        <a href="#handPopup" data-rel="popup" data-role="button" data-theme="a" data-icon="gear" data-position-to="header" data-transition="slideup">Hand</a>
    </div>
    <div class="ui-block-d">
        <a href="#autoPopup" data-rel="popup" data-role="button" data-theme="a" data-icon="gear" data-position-to="header" data-transition="slideup">Auto</a>
    </div>
    <div class="ui-block-e">
        <a href="#offPopup" data-rel="popup" data-role="button" data-theme="a" data-icon="gear" data-position-to="header" data-transition="slideup">Off</a>
    </div>
</div>

我知道这不是让它工作的正确 CSS,我尝试了一些不同的东西,但这里是标准的响应式 CSS

@media all and (max-width: 300px) {
.my-breakpoint .ui-block-a, 
.my-breakpoint .ui-block-b, 
.my-breakpoint .ui-block-c,
.my-breakpoint .ui-block-d,
.my-breakpoint .ui-block-e { 
    width: 100%; 
    float:none; 
 }
}

有人对如何做到这一点有任何想法吗?

谢谢!

4

2 回答 2

2

为了重新排列这些 div 的流动位置,您要么必须将它们绝对定位到你想要它们的位置 [使用 CSS],要么将节点物理移动到你想要它们的位置 [使用 JS]。

第三种解决方案,您可以将初始 html/css 重新排列为如下所示:

HTML

<div class="ui-grid-d my-breakpoint">
    <div class="ui-block-a">
        <input type="image" id="jog" src="images/jog.gif">
        <a href="#jogPopup" data-rel="popup" data-role="button"  data-theme="a" data-icon="gear" data-position-to="header">Jog</a>
    </div>
</div>

CSS

.my-breakpoint .ui-block-a a {
    margin-top:25px;
}

从本质上讲,这将为您的“非折叠”视图提供两个堆叠行的效果。然后,在您的媒体查询中,您可以将所有AINPUT元素设置display:block为让它们形成一个堆叠列(它们自然会按照您想要的方式堆叠)。

我摆弄了这个想法,有点冲淡了:http: //jsfiddle.net/BddhH/

于 2013-06-14T16:59:01.227 回答
-1

移动电网的简单解决方案

只是扩展引导网格 - 像这样

    @media (min-width: 768px) {
    .container {
        width: 766px;
        padding-right: 2px;
        padding-left: 2px;
        margin-right: auto;
        margin-left: auto;
    }

    .mob-xs-1, .mob-sm-1, .mob-xs-2, .mob-sm-2, .mob-xs-3, .mob-sm-3, .mob-xs-4, .mob-sm-4, .mob-xs-5, .mob-sm-5, .mob-xs-6, .mob-sm-6, .mob-xs-7, .mob-sm-7, .mob-xs-8, .mob-sm-8, .mob-xs-9, .mob-sm-9, .mob-xs-10, .mob-sm-10, .mob-xs-11, .mob-sm-11, .mob-xs-12, .mob-sm-12 {
        position: relative;
        min-height: 1px;
        padding-right: 2px;
        padding-left: 2px;
    }


    .container-fluid {
        padding-right: 2px;
        padding-left: 2px;
        margin-right: auto;
        margin-left: auto;
    }

    .row {
        margin-right: -2px;
        margin-left: -2px;
    }
}



.mob-xs-1, .mob-xs-2, .mob-xs-3, .mob-xs-4, .mob-xs-5, .mob-xs-6, .mob-xs-7, .mob-xs-8, .mob-xs-9, .mob-xs-10, .mob-xs-11, .mob-xs-12 {
    float: left;
}

.mob-xs-12 {
    width: 100%;
}

.mob-xs-11 {
    width: 91.66666667%;
}

.mob-xs-10 {
    width: 83.33333333%;
}

.mob-xs-9 {
    width: 75%;
}

.mob-xs-8 {
    width: 66.66666667%;
}

.mob-xs-7 {
    width: 58.33333333%;
}

.mob-xs-6 {
    width: 50%;
}

.mob-xs-5 {
    width: 41.66666667%;
}

.mob-xs-4 {
    width: 33.33333333%;
}

.mob-xs-3 {
    width: 25%;
}

.mob-xs-2 {
    width: 16.66666667%;
}

.mob-xs-1 {
    width: 8.33333333%;
}

.mob-xs-pull-12 {
    right: 100%;
}

.mob-xs-pull-11 {
    right: 91.66666667%;
}

.mob-xs-pull-10 {
    right: 83.33333333%;
}

.mob-xs-pull-9 {
    right: 75%;
}

.mob-xs-pull-8 {
    right: 66.66666667%;
}

.mob-xs-pull-7 {
    right: 58.33333333%;
}

.mob-xs-pull-6 {
    right: 50%;
}

.mob-xs-pull-5 {
    right: 41.66666667%;
}

.mob-xs-pull-4 {
    right: 33.33333333%;
}

.mob-xs-pull-3 {
    right: 25%;
}

.mob-xs-pull-2 {
    right: 16.66666667%;
}

.mob-xs-pull-1 {
    right: 8.33333333%;
}

.mob-xs-pull-0 {
    right: auto;
}

.mob-xs-push-12 {
    left: 100%;
}

.mob-xs-push-11 {
    left: 91.66666667%;
}

.mob-xs-push-10 {
    left: 83.33333333%;
}

.mob-xs-push-9 {
    left: 75%;
}

.mob-xs-push-8 {
    left: 66.66666667%;
}

.mob-xs-push-7 {
    left: 58.33333333%;
}

.mob-xs-push-6 {
    left: 50%;
}

.mob-xs-push-5 {
    left: 41.66666667%;
}

.mob-xs-push-4 {
    left: 33.33333333%;
}

.mob-xs-push-3 {
    left: 25%;
}

.mob-xs-push-2 {
    left: 16.66666667%;
}

.mob-xs-push-1 {
    left: 8.33333333%;
}

.mob-xs-push-0 {
    left: auto;
}

.mob-xs-offset-12 {
    margin-left: 100%;
}

.mob-xs-offset-11 {
    margin-left: 91.66666667%;
}

.mob-xs-offset-10 {
    margin-left: 83.33333333%;
}

.mob-xs-offset-9 {
    margin-left: 75%;
}

.mob-xs-offset-8 {
    margin-left: 66.66666667%;
}

.mob-xs-offset-7 {
    margin-left: 58.33333333%;
}

.mob-xs-offset-6 {
    margin-left: 50%;
}

.mob-xs-offset-5 {
    margin-left: 41.66666667%;
}

.mob-xs-offset-4 {
    margin-left: 33.33333333%;
}

.mob-xs-offset-3 {
    margin-left: 25%;
}

.mob-xs-offset-2 {
    margin-left: 16.66666667%;
}

.mob-xs-offset-1 {
    margin-left: 8.33333333%;
}

.mob-xs-offset-0 {
    margin-left: 0;
}

@media (min-width: 768px) {
    .mob-sm-1, .mob-sm-2, .mob-sm-3, .mob-sm-4, .mob-sm-5, .mob-sm-6, .mob-sm-7, .mob-sm-8, .mob-sm-9, .mob-sm-10, .mob-sm-11, .mob-sm-12 {
        float: left;
    }

    .mob-sm-12 {
        width: 100%;
    }

    .mob-sm-11 {
        width: 91.66666667%;
    }

    .mob-sm-10 {
        width: 83.33333333%;
    }

    .mob-sm-9 {
        width: 75%;
    }

    .mob-sm-8 {
        width: 66.66666667%;
    }

    .mob-sm-7 {
        width: 58.33333333%;
    }

    .mob-sm-6 {
        width: 50%;
    }

    .mob-sm-5 {
        width: 41.66666667%;
    }

    .mob-sm-4 {
        width: 33.33333333%;
    }

    .mob-sm-3 {
        width: 25%;
    }

    .mob-sm-2 {
        width: 16.66666667%;
    }

    .mob-sm-1 {
        width: 8.33333333%;
    }

    .mob-sm-pull-12 {
        right: 100%;
    }

    .mob-sm-pull-11 {
        right: 91.66666667%;
    }

    .mob-sm-pull-10 {
        right: 83.33333333%;
    }

    .mob-sm-pull-9 {
        right: 75%;
    }

    .mob-sm-pull-8 {
        right: 66.66666667%;
    }

    .mob-sm-pull-7 {
        right: 58.33333333%;
    }

    .mob-sm-pull-6 {
        right: 50%;
    }

    .mob-sm-pull-5 {
        right: 41.66666667%;
    }

    .mob-sm-pull-4 {
        right: 33.33333333%;
    }

    .mob-sm-pull-3 {
        right: 25%;
    }

    .mob-sm-pull-2 {
        right: 16.66666667%;
    }

    .mob-sm-pull-1 {
        right: 8.33333333%;
    }

    .mob-sm-pull-0 {
        right: auto;
    }

    .mob-sm-push-12 {
        left: 100%;
    }

    .mob-sm-push-11 {
        left: 91.66666667%;
    }

    .mob-sm-push-10 {
        left: 83.33333333%;
    }

    .mob-sm-push-9 {
        left: 75%;
    }

    .mob-sm-push-8 {
        left: 66.66666667%;
    }

    .mob-sm-push-7 {
        left: 58.33333333%;
    }

    .mob-sm-push-6 {
        left: 50%;
    }

    .mob-sm-push-5 {
        left: 41.66666667%;
    }

    .mob-sm-push-4 {
        left: 33.33333333%;
    }

    .mob-sm-push-3 {
        left: 25%;
    }

    .mob-sm-push-2 {
        left: 16.66666667%;
    }

    .mob-sm-push-1 {
        left: 8.33333333%;
    }

    .mob-sm-push-0 {
        left: auto;
    }

    .mob-sm-offset-12 {
        margin-left: 100%;
    }

    .mob-sm-offset-11 {
        margin-left: 91.66666667%;
    }

    .mob-sm-offset-10 {
        margin-left: 83.33333333%;
    }

    .mob-sm-offset-9 {
        margin-left: 75%;
    }

    .mob-sm-offset-8 {
        margin-left: 66.66666667%;
    }

    .mob-sm-offset-7 {
        margin-left: 58.33333333%;
    }

    .mob-sm-offset-6 {
        margin-left: 50%;
    }

    .mob-sm-offset-5 {
        margin-left: 41.66666667%;
    }

    .mob-sm-offset-4 {
        margin-left: 33.33333333%;
    }

    .mob-sm-offset-3 {
        margin-left: 25%;
    }

    .mob-sm-offset-2 {
        margin-left: 16.66666667%;
    }

    .mob-sm-offset-1 {
        margin-left: 8.33333333%;
    }

    .mob-sm-offset-0 {
        margin-left: 0;
    }
}


@-ms-viewport {
    width: device-width;
}

.visible-xs,
.visible-sm {
    display: none !important;
}

.visible-xs-block,
.visible-xs-inline,
.visible-xs-inline-block,
.visible-sm-block,
.visible-sm-inline,
.visible-sm-inline-block {
    display: none !important;
}

@media (max-width: 767px) {
    .visible-xs {
        display: block !important;
    }

    table.visible-xs {
        display: table !important;
    }

    tr.visible-xs {
        display: table-row !important;
    }

    th.visible-xs,
    td.visible-xs {
        display: table-cell !important;
    }
}

@media (max-width: 767px) {
    .visible-xs-block {
        display: block !important;
    }
}

@media (max-width: 767px) {
    .visible-xs-inline {
        display: inline !important;
    }
}

@media (max-width: 767px) {
    .visible-xs-inline-block {
        display: inline-block !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .visible-sm {
        display: block !important;
    }

    table.visible-sm {
        display: table !important;
    }

    tr.visible-sm {
        display: table-row !important;
    }

    th.visible-sm,
    td.visible-sm {
        display: table-cell !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .visible-sm-block {
        display: block !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .visible-sm-inline {
        display: inline !important;
    }
}


@media (min-width: 992px) and (max-width: 1199px) {

    @media (max-width: 767px) {
        .hidden-xs {
            display: none !important;
        }
    }

    @media (min-width: 768px) and (max-width: 991px) {
        .hidden-sm {
            display: none !important;
        }
    }
}
于 2015-09-28T06:10:31.427 回答