封装十二栅格

媒体查询技术 : 当前文档打开的设备类型,或者同一设备的不同状态,来引入不同的样式表,实现样式布局的适配变化。

/* 栅格的父级容器 */
.row{
    /* 宽度不设置,magin 设置负值 */
    margin: 0px -15px;
}
/* 子级浮动同行排列,清浮动 */
.row::after{
    content: "";
    display: block;
    clear: both;
}
.col-xs-1,.col-xs-2,.col-xs-3,
.col-xs-4,.col-xs-5,.col-xs-6,
.col-xs-7,.col-xs-8,.col-xs-9,
.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-15{
    float: left;
    box-sizing: border-box;
    padding: 0 15px;
    /* border: 1px solid blue; */
    
}
.col-xs-1{width: calc(100% * 1 / 12);}
.col-xs-2{width: calc(100% * 2 / 12);}
.col-xs-3{width: calc(100% * 3 / 12);}
.col-xs-4{width: calc(100% * 4 / 12);}
.col-xs-5{width: calc(100% * 5 / 12);}
.col-xs-6{width: calc(100% * 6 / 12);}
.col-xs-7{width: calc(100% * 7 / 12);}
.col-xs-8{width: calc(100% * 8 / 12);}
.col-xs-9{width: calc(100% * 9 / 12);}
.col-xs-10{width: calc(100% * 10 / 12);}
.col-xs-11{width: calc(100% * 11 / 12);}
.col-xs-12{width: calc(100% * 12 / 12);}
.col-xs-15{width: calc(100% * 1.5 / 12);}


/* 封装偏移量 */
.col-xs-offset-1{margin-left: calc(100% * 1 / 12);}
.col-xs-offset-2{margin-left: calc(100% * 2 / 12);}
.col-xs-offset-3{margin-left: calc(100% * 3 / 12);}
.col-xs-offset-4{margin-left: calc(100% * 4 / 12);}
.col-xs-offset-5{margin-left: calc(100% * 5 / 12);}
.col-xs-offset-6{margin-left: calc(100% * 6 / 12);}
.col-xs-offset-7{margin-left: calc(100% * 7 / 12);}
.col-xs-offset-8{margin-left: calc(100% * 8 / 12);}
.col-xs-offset-9{margin-left: calc(100% * 9 / 12);}
.col-xs-offset-10{margin-left: calc(100% * 10 / 12);}
.col-xs-offset-11{margin-left: calc(100% * 11 / 12);}
.col-xs-offset-12{margin-left: calc(100% * 12 / 12);}

/* 相对定位  向左*/
.col-xs-push-1{
    position: relative;
    left: calc(100% * 1 / 12);
}
.col-xs-push-2{
    position: relative;
    left: calc(100% * 2 / 12);
}
.col-xs-push-3{
    position: relative;
    left: calc(100% * 3 / 12);
}
.col-xs-push-4{
    position: relative;
    left: calc(100% * 4 / 12);
}
.col-xs-push-5{
    position: relative;
    left: calc(100% * 5 / 12);
}
.col-xs-push-6{
    position: relative;
    left: calc(100% * 6 / 12);
}
.col-xs-push-7{
    position: relative;
    left: calc(100% * 7 / 12);
}
.col-xs-push-8{
    position: relative;
    left: calc(100% * 8 / 12);
}
.col-xs-push-9{
    position: relative;
    left: calc(100% * 9 / 12);
}
.col-xs-push-10{
    position: relative;
    left: calc(100% * 10 / 12);
}
.col-xs-push-11{
    position: relative;
    left: calc(100% * 11 / 12);
}
.col-xs-push-12{
    position: relative;
    left: calc(100% * 12 / 12);
}



/* 相对定位  向右 */
.col-xs-pull-1{
    position: relative;
    right: calc(100% * 1 / 12);
}
.col-xs-pull-2{
    position: relative;
    right: calc(100% * 2 / 12);
}
.col-xs-pull-3{
    position: relative;
    right: calc(100% * 3 / 12);
}
.col-xs-pull-4{
    position: relative;
    right: calc(100% * 4 / 12);
}
.col-xs-pull-5{
    position: relative;
    right: calc(100% * 5 / 12);
}
.col-xs-pull-6{
    position: relative;
    right: calc(100% * 6 / 12);
}
.col-xs-pull-7{
    position: relative;
    right: calc(100% * 7 / 12);
}
.col-xs-pull-8{
    position: relative;
    right: calc(100% * 8 / 12);
}
.col-xs-pull-9{
    position: relative;
    right: calc(100% * 9 / 12);
}
.col-xs-pull-10{
    position: relative;
    right: calc(100% * 10 / 12);
}
.col-xs-pull-11{
    position: relative;
    right: calc(100% * 11 / 12);
}
.col-xs-pull-12{
    position: relative;
    right: calc(100% * 12 / 12);
}





/* 768px以上   768px--992px之间*/

@media screen and (min-width:768px){
.col-sm-1,.col-sm-2,.col-sm-3,
.col-sm-4,.col-sm-5,.col-sm-6,
.col-sm-7,.col-sm-8,.col-sm-9,
.col-sm-10,.col-sm-11,.col-sm-12{
    float: left;
    box-sizing: border-box;
    padding: 0 15px;
    /* border: 1px solid blue; */
    
}
.col-sm-1{width: calc(100% * 1 / 12);}
.col-sm-2{width: calc(100% * 2 / 12);}
.col-sm-3{width: calc(100% * 3 / 12);}
.col-sm-4{width: calc(100% * 4 / 12);}
.col-sm-5{width: calc(100% * 5 / 12);}
.col-sm-6{width: calc(100% * 6 / 12);}
.col-sm-7{width: calc(100% * 7 / 12);}
.col-sm-8{width: calc(100% * 8 / 12);}
.col-sm-9{width: calc(100% * 9 / 12);}
.col-sm-10{width: calc(100% * 10 / 12);}
.col-sm-11{width: calc(100% * 11 / 12);}
/* .col-sm-12{width: calc(100% * 12 / 12);} */

/* 封装偏移量 */
.col-sm-offset-1{margin-left: calc(100% * 1 / 12);}
.col-sm-offset-2{margin-left: calc(100% * 2 / 12);}
.col-sm-offset-3{margin-left: calc(100% * 3 / 12);}
.col-sm-offset-4{margin-left: calc(100% * 4 / 12);}
.col-sm-offset-5{margin-left: calc(100% * 5 / 12);}
.col-sm-offset-6{margin-left: calc(100% * 6 / 12);}
.col-sm-offset-7{margin-left: calc(100% * 7 / 12);}
.col-sm-offset-8{margin-left: calc(100% * 8 / 12);}
.col-sm-offset-9{margin-left: calc(100% * 9 / 12);}
.col-sm-offset-10{margin-left: calc(100% * 10 / 12);}
.col-sm-offset-11{margin-left: calc(100% * 11 / 12);}
/* .col-sm-offset-12{margin-left: calc(100% * 12 / 12);} */

/* 相对定位 */
.col-sm-push-1{
    position: relative;
    left: calc(100% * 1 / 12);
}
.col-sm-push-2{
    position: relative;
    left: calc(100% * 2 / 12);
}
.col-sm-push-3{
    position: relative;
    left: calc(100% * 3 / 12);
}
.col-sm-push-4{
    position: relative;
    left: calc(100% * 4 / 12);
}
.col-sm-push-5{
    position: relative;
    left: calc(100% * 5 / 12);
}
.col-sm-push-6{
    position: relative;
    left: calc(100% * 6 / 12);
}
.col-sm-push-7{
    position: relative;
    left: calc(100% * 7 / 12);
}
.col-sm-push-8{
    position: relative;
    left: calc(100% * 8 / 12);
}
.col-sm-push-9{
    position: relative;
    left: calc(100% * 9 / 12);
}
.col-sm-push-10{
    position: relative;
    left: calc(100% * 10 / 12);
}
.col-sm-push-11{
    position: relative;
    left: calc(100% * 11 / 12);
}
/* .col-sm-push-12{
    position: relative;
    left: calc(100% * 12 / 12);
} */

/* 向右 */
.col-sm-pull-1{
    position: relative;
    right: calc(100% * 1 / 12);
}
.col-sm-pull-2{
    position: relative;
    right: calc(100% * 2 / 12);
}
.col-sm-pull-3{
    position: relative;
    right: calc(100% * 3 / 12);
}
.col-sm-pull-4{
    position: relative;
    right: calc(100% * 4 / 12);
}
.col-sm-pull-5{
    position: relative;
    right: calc(100% * 5 / 12);
}
.col-sm-pull-6{
    position: relative;
    right: calc(100% * 6 / 12);
}
.col-sm-pull-7{
    position: relative;
    right: calc(100% * 7 / 12);
}
.col-sm-pull-8{
    position: relative;
    right: calc(100% * 8 / 12);
}
.col-sm-pull-9{
    position: relative;
    right: calc(100% * 9 / 12);
}
.col-sm-pull-10{
    position: relative;
    right: calc(100% * 10 / 12);
}
.col-sm-pull-11{
    position: relative;
    right: calc(100% * 11 / 12);
}
/* .col-sm-pull-12{
    position: relative;
    right: calc(100% * 12 / 12);
} */
}



/*992px以上  992px--1200px 之间 */

@media screen and (min-width:992px){
.col-md-1,.col-md-2,.col-md-3,
.col-md-4,.col-md-5,.col-md-6,
.col-md-7,.col-md-8,.col-md-9,
.col-md-10,.col-md-11,.col-md-12{
    float: left;
    box-sizing: border-box;
    padding: 0 15px;
    /* border: 1px solid blue; */
    
}
.col-md-1{width: calc(100% * 1 / 12);}
.col-md-2{width: calc(100% * 2 / 12);}
.col-md-3{width: calc(100% * 3 / 12);}
.col-md-4{width: calc(100% * 4 / 12);}
.col-md-5{width: calc(100% * 5 / 12);}
.col-md-6{width: calc(100% * 6 / 12);}
.col-md-7{width: calc(100% * 7 / 12);}
.col-md-8{width: calc(100% * 8 / 12);}
.col-md-9{width: calc(100% * 9 / 12);}
.col-md-10{width: calc(100% * 10 / 12);}
.col-md-11{width: calc(100% * 11 / 12);}
/* .col-md-12{width: calc(100% * 12 / 12);} */

/* 封装偏移量 */
.col-md-offset-1{margin-left: calc(100% * 1 / 12);}
.col-md-offset-2{margin-left: calc(100% * 2 / 12);}
.col-md-offset-3{margin-left: calc(100% * 3 / 12);}
.col-md-offset-4{margin-left: calc(100% * 4 / 12);}
.col-md-offset-5{margin-left: calc(100% * 5 / 12);}
.col-md-offset-6{margin-left: calc(100% * 6 / 12);}
.col-md-offset-7{margin-left: calc(100% * 7 / 12);}
.col-md-offset-8{margin-left: calc(100% * 8 / 12);}
.col-md-offset-9{margin-left: calc(100% * 9 / 12);}
.col-md-offset-10{margin-left: calc(100% * 10 / 12);}
.col-md-offset-11{margin-left: calc(100% * 11 / 12);}
/* .col-md-offset-12{margin-left: calc(100% * 12 / 12);} */

/* 相对定位 */
.col-md-push-1{
    position: relative;
    left: calc(100% * 1 / 12);
}
.col-md-push-2{
    position: relative;
    left: calc(100% * 2 / 12);
}
.col-md-push-3{
    position: relative;
    left: calc(100% * 3 / 12);
}
.col-md-push-4{
    position: relative;
    left: calc(100% * 4 / 12);
}
.col-md-push-5{
    position: relative;
    left: calc(100% * 5 / 12);
}
.col-md-push-6{
    position: relative;
    left: calc(100% * 6 / 12);
}
.col-md-push-7{
    position: relative;
    left: calc(100% * 7 / 12);
}
.col-md-push-8{
    position: relative;
    left: calc(100% * 8 / 12);
}
.col-md-push-9{
    position: relative;
    left: calc(100% * 9 / 12);
}
.col-md-push-10{
    position: relative;
    left: calc(100% * 10 / 12);
}
.col-md-push-11{
    position: relative;
    left: calc(100% * 11 / 12);
}
/* .col-md-push-12{
    position: relative;
    left: calc(100% * 12 / 12);
} */

/* 向右 */
.col-md-pull-1{
    position: relative;
    right: calc(100% * 1 / 12);
}
.col-md-pull-2{
    position: relative;
    right: calc(100% * 2 / 12);
}
.col-md-pull-3{
    position: relative;
    right: calc(100% * 3 / 12);
}
.col-md-pull-4{
    position: relative;
    right: calc(100% * 4 / 12);
}
.col-md-pull-5{
    position: relative;
    right: calc(100% * 5 / 12);
}
.col-md-pull-6{
    position: relative;
    right: calc(100% * 6 / 12);
}
.col-md-pull-7{
    position: relative;
    right: calc(100% * 7 / 12);
}
.col-md-pull-8{
    position: relative;
    right: calc(100% * 8 / 12);
}
.col-md-pull-9{
    position: relative;
    right: calc(100% * 9 / 12);
}
.col-md-pull-10{
    position: relative;
    right: calc(100% * 10 / 12);
}
.col-md-pull-11{
    position: relative;
    right: calc(100% * 11 / 12);
}
/* .col-md-pull-12{
    position: relative;
    right: calc(100% * 12 / 12);
} */
}



/* 1200px以上 */
@media screen and (min-width:1200px){
.col-lg-1,.col-lg-2,.col-lg-3,
.col-lg-4,.col-lg-5,.col-lg-6,
.col-lg-7,.col-lg-8,.col-lg-9,
.col-lg-10,.col-lg-11,.col-lg-12{
    float: left;
    box-sizing: border-box;
    padding: 0 15px;
    /* border: 1px solid blue; */
    
}
.col-lg-1{width: calc(100% * 1 / 12);}
.col-lg-2{width: calc(100% * 2 / 12);}
.col-lg-3{width: calc(100% * 3 / 12);}
.col-lg-4{width: calc(100% * 4 / 12);}
.col-lg-5{width: calc(100% * 5 / 12);}
.col-lg-6{width: calc(100% * 6 / 12);}
.col-lg-7{width: calc(100% * 7 / 12);}
.col-lg-8{width: calc(100% * 8 / 12);}
.col-lg-9{width: calc(100% * 9 / 12);}
.col-lg-10{width: calc(100% * 10 / 12);}
.col-lg-11{width: calc(100% * 11 / 12);}
/* .col-lg-12{width: calc(100% * 12 / 12);} */

/* 封装偏移量 */
.col-lg-offset-1{margin-left: calc(100% * 1 / 12);}
.col-lg-offset-2{margin-left: calc(100% * 2 / 12);}
.col-lg-offset-3{margin-left: calc(100% * 3 / 12);}
.col-lg-offset-4{margin-left: calc(100% * 4 / 12);}
.col-lg-offset-5{margin-left: calc(100% * 5 / 12);}
.col-lg-offset-6{margin-left: calc(100% * 6 / 12);}
.col-lg-offset-7{margin-left: calc(100% * 7 / 12);}
.col-lg-offset-8{margin-left: calc(100% * 8 / 12);}
.col-lg-offset-9{margin-left: calc(100% * 9 / 12);}
.col-lg-offset-10{margin-left: calc(100% * 10 / 12);}
.col-lg-offset-11{margin-left: calc(100% * 11 / 12);}
/* .col-lg-offset-12{margin-left: calc(100% * 12 / 12);} */

/* 相对定位 */
.col-lg-push-1{
    position: relative;
    left: calc(100% * 1 / 12);
}
.col-lg-push-2{
    position: relative;
    left: calc(100% * 2 / 12);
}
.col-lg-push-3{
    position: relative;
    left: calc(100% * 3 / 12);
}
.col-lg-push-4{
    position: relative;
    left: calc(100% * 4 / 12);
}
.col-lg-push-5{
    position: relative;
    left: calc(100% * 5 / 12);
}
.col-lg-push-6{
    position: relative;
    left: calc(100% * 6 / 12);
}
.col-lg-push-7{
    position: relative;
    left: calc(100% * 7 / 12);
}
.col-lg-push-8{
    position: relative;
    left: calc(100% * 8 / 12);
}
.col-lg-push-9{
    position: relative;
    left: calc(100% * 9 / 12);
}
.col-lg-push-10{
    position: relative;
    left: calc(100% * 10 / 12);
}
.col-lg-push-11{
    position: relative;
    left: calc(100% * 11 / 12);
}
/* .col-lg-push-12{
    position: relative;
    left: calc(100% * 12 / 12);
} */

/* 向右 */
.col-lg-pull-1{
    position: relative;
    right: calc(100% * 1 / 12);
}
.col-lg-pull-2{
    position: relative;
    right: calc(100% * 2 / 12);
}
.col-lg-pull-3{
    position: relative;
    right: calc(100% * 3 / 12);
}
.col-lg-pull-4{
    position: relative;
    right: calc(100% * 4 / 12);
}
.col-lg-pull-5{
    position: relative;
    right: calc(100% * 5 / 12);
}
.col-lg-pull-6{
    position: relative;
    right: calc(100% * 6 / 12);
}
.col-lg-pull-7{
    position: relative;
    right: calc(100% * 7 / 12);
}
.col-lg-pull-8{
    position: relative;
    right: calc(100% * 8 / 12);
}
.col-lg-pull-9{
    position: relative;
    right: calc(100% * 9 / 12);
}
.col-lg-pull-10{
    position: relative;
    right: calc(100% * 10 / 12);
}
.col-lg-pull-11{
    position: relative;
    right: calc(100% * 11 / 12);
}
/* .col-lg-pull-12{
    position: relative;
    right: calc(100% * 12 / 12);
} */
}

/* 响应式栅格使用技巧
    1、只需要栅格,不需要响应式固定尺寸布局  xs
    两个区间
    2、以768为界   xs  sm
    3、以992为界   xs  md
    4、以1200为界  xs  lg

    三个区间
    --768--992--
    xs   sm    md
    --992--1200--
    xs   md    lg
    --768--1200--
    xs   sm    lg

    四个区间
    --768--992--1200--
    xs   sm   md    lg
*/



              /*可见性问题 */

    /* 可见性封装 */
.show-xs-block,.show-xs-inline-block,
.show-sm-block,.show-xs-inline-block,
.show-md-block,.show-xs-inline-block,
.show-lg-block,.show-xs-inline-block{
      display: none;   /* 隐藏 */
}

/* 768px以下可见 */
@media screen and (max-width:768px){
    .show-xs-block{
        display: block;
    }
    .show-xs-inline-block{
        display:inline-block;
    }
}

/* 768px--992px */
@media screen and (min-width:769px) and (max-width:992px){
    .show-xs-block{
        display: block;
    }
    .show-xs-inline-block{
        display: inline-block;
    }
}

/* 992px--1200px */
@media screen and (min-width:993px) and (max-width:1200px){
    .show-xs-block{
        display: block;
    }
    .show-xs-inline-block{
        display:inline-block;
    }
}

/* 1200px以上 */
@media screen and (min-width:1201px){
    .show-xs-block{
        display: block;
    }
    .show-xs-inline-block{
        display:inline-block;
    }
}

       /* 隐藏性封装 */

/* 768px以下隐藏 */
@media screen and (max-width:768px){
    .hide-xs{display: none;}
}

/* 768px--992px */
@media screen and (min-width:769px) and (max-width:992px){
    .hide-sm{display: none;}
}

/* 992px--1200px */
@media screen and (min-width:993px) and (max-width:1200px){
    .hide-md{display: none;}
}

/* 1200px以上 */
@media screen and (min-width:1201px){
    .hide-lg{display: none;}
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,193评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,306评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,130评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,110评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,118评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,085评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,007评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,844评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,283评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,508评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,667评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,395评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,985评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,630评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,797评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,653评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,553评论 2 352

推荐阅读更多精彩内容