媒体查询技术 : 当前文档打开的设备类型,或者同一设备的不同状态,来引入不同的样式表,实现样式布局的适配变化。
/* 栅格的父级容器 */
.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;}
}
网友评论