响应分宽度

时间:2015-10-20 15:05:17

标签: css grid width responsiveness

我想做几个'块'文本来自:

|1| |2| |3| |4| |5| |6|

在比平板电脑宽的屏幕上观看时,根据较小的屏幕尺寸进行响应,如下所示:

在平板电脑上:

| 1 | | 2 | | 3 |

| 4 | | 5 | | 6 |

在手机上:

|1|

|2|

|3|

|4|

|5|

|6|

以下是该网页的网址链接:

create.qublu.com/rates

页面的全宽为980像素。我需要的是每个div根据所查看的屏幕尺寸具有响应宽度并在屏幕上居中。

正如您将在页面上看到的,有四个切换按钮。 1级,2级,3级和4级.2级工作绝对精细和完美。但是当在大屏幕上观看时,1级上的所有街区都没有排队。相反,块显示3个块×2行。很沮丧!

这是我正在使用的CSS代码:

.col-xs-1,
.col-sm-1,
.col-md-1,
.col-lg-1 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-1 {
    width: 8.33%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-1 {
    width: 8.33%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-1 {
    width: 8.33%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-1 {
    width: 8.33%;
    float: left;
    }
}
.col-xs-2,
.col-sm-2,
.col-md-2,
.col-lg-2 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-2 {
    width: 16.66%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-2 {
    width: 16.66%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-2 {
    width: 16.66%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-2 {
        width: 16.66%;
        float: left;
    }
}
.col-xs-3,
.col-sm-3,
.col-md-3,
.col-lg-3 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-3 {
    width: 25%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-3 {
    width: 25%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-3 {
    width: 25%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-3 {
        width: 25%;
        float: left;
    }
}
.col-xs-4,
.col-sm-4,
.col-md-4,
.col-lg-4 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-4 {
    width: 33.33%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-4 {
    width: 33.33%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-4 {
    width: 33.33%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-4 {
        width: 33.33%;
        float: left;
    }
}
.col-xs-5,
.col-sm-5,
.col-md-5,
.col-lg-5 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-5 {
    width: 41.66%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-5 {
    width: 41.66%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-5 {
    width: 41.66%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-5 {
        width: 41.66%;
        float: left;
    }
}
.col-xs-6,
.col-sm-6,
.col-md-6,
.col-lg-6 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-6 {
    width: 50%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-6 {
    width: 50%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-6 {
    width: 50%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-6 {
        width: 50%;
        float: left;
    }
}
.col-xs-7,
.col-sm-7,
.col-md-7,
.col-lg-7 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-7 {
    width: 58.47%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-7 {
    width: 58.47%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-7 {
    width: 58.47%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-7 {
        width: 58.47%;
        float: left;
    }
}
.col-xs-8,
.col-sm-8,
.col-md-8,
.col-lg-8 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-8 {
    width: 66.66%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-8 {
    width: 66.66%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-8 {
    width: 66.66%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-8 {
        width: 66.66%;
        float: left;
    }
}
.col-xs-9,
.col-sm-9,
.col-md-9,
.col-lg-9 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-9 {
    width: 75%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-9 {
    width: 75%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-9 {
    width: 75%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-9 {
        width: 75%;
        float: left;
    }
}
.col-xs-10,
.col-sm-10,
.col-md-10,
.col-lg-10 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-10 {
    width: 83.33%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-10 {
    width: 83.33%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-10 {
    width: 83.33%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-10 {
        width: 83.33%;
        float: left;
    }
}
.col-xs-11,
.col-sm-11,
.col-md-11,
.col-lg-11 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-11 {
    width: 91.74%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-11 {
    width: 91.74%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-11 {
    width: 91.74%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-11 {
        width: 91.74%;
        float: left;
    }
}
.col-xs-12,
.col-sm-12,
.col-md-12,
.col-lg-12 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-12 {
    width: 99%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-12 {
    width: 99%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-12 {
    width: 99%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-12 {
        width: 99%;
        float: left;
    }
}
.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
    position: relative;
    min-height: 1px;
    padding-right: 0px;
    padding-left: 0px;
}
.col-xs-15 {
    width: 20%;
    float: left;
}
@media (min-width: 321px) {
.col-sm-15 {
    width: 20%;
    float: left;
    }
}
@media (min-width: 699px) {
.col-md-15 {
    width: 20%;
    float: left;
    }
}
@media (min-width: 979px) {
.col-lg-15 {
    width: 20%;
    float: left;
    }
}

1 个答案:

答案 0 :(得分:0)

看看这里: http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

要在一行中有6列,您可以使用 col-XX-2 - 其中XX是屏幕尺寸缩写

在您的示例中,“ col-md-2 ”用作level-1 div的类将导致:

| 1 | | 2 | | 3 | | 4 | | 5 | | 6 |