Html 使CSS中的网格系统响应移动设备
我正在用CSS制作我的网格系统。我已经为它编写了以下代码,它运行良好。但我想知道如何使这种布局对小于600px的移动设备做出响应。代码片段如下所示Html 使CSS中的网格系统响应移动设备,html,css,html5-canvas,Html,Css,Html5 Canvas,我正在用CSS制作我的网格系统。我已经为它编写了以下代码,它运行良好。但我想知道如何使这种布局对小于600px的移动设备做出响应。代码片段如下所示 .grid-container { width: 100%; max-width: auto; } /*-- our cleafix hack -- */ .row:before,.row:after { content: ""; display: table; clear: both; } [class*
.grid-container {
width: 100%;
max-width: auto;
}
/*-- our cleafix hack -- */
.row:before,.row:after {
content: "";
display: table;
clear: both;
}
[class*='col-'] {
float: left;
min-height: 1px;
width: 16.66%;
/*-- our gutter -- */
padding: 12px;
background-color: #FFDCDC;
}
.col-1 {
width: 16.66%;
}
.col-2 {
width: 31%;
}
.col-3 {
width: 48%;
}
.col-4 {
width: 66.66%;
}
.col-5 {
width: 83.33%;
}
.col-6 {
width: 100%;
}
.outline,.outline * {
outline: 1px solid #F6A1A1;
}
/*-- some extra column content styling --*/
[class*='col-']>p {
background-color: #FFC2C2;
padding: 0;
margin: 0;
text-align: center;
color: white;
}`enter code here`
请帮帮我 要使其在不同大小上工作,必须使用媒体查询。 更多信息: 目前我知道两种工作方法: 1) 类操作:覆盖匹配媒体查询的类属性,例如:
@media only screen and (max-width: 600px) { //apply if screen is < 600px
.col-5 { width: 50% } // overwrite the width of 83.33% to 50%
}
我只是像你一样学习:D
对不起,我的英语不好,我已经尽了最大的努力了。D:你做过任何研究或搜索响应CSS吗?“媒体查询”一词应该对我是网络开发新手有所帮助。我被告知使用%而不是px来让网站响应如果你有任何问题(是的,你有:/),我很乐意明天帮你,现在我要睡觉了:D
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
.container {
width: 1060px;
max-width: 96%;
margin: 0 auto;
}
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}