【发布时间】:2016-06-06 08:48:34
【问题描述】:
我完全是响应式设计的新手。我的媒体查询不起作用。当我调整窗口大小时,我猜它不会重新调整断点。我制作了两个 div,其中一个用于桌面视图,另一个用于平板电脑视图。我使用 display: none 属性来拥有桌面和移动版本。
另一个问题是,有没有办法为所有移动设备配置媒体查询?或者我应该为每个方便的群体写 css 吗? (如 iphone5、iphone6、nexus 等)
.tablet-view{
display: none;
}
.desktop-view{
display: inline;
}
/* ----------- iPad mini ----------- */
/* Portrait and Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Portrait */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* ----------- iPad 1 and 2 ----------- */
/* Portrait and Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Portrait */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 1) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* ----------- iPad 3 and 4 ----------- */
/* Portrait and Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (-webkit-min-device-pixel-ratio: 2) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Portrait */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 2) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
/* Landscape */
@media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 2) {
.desktop-view{
display:none;
}.tablet-view {
display: inline;
}
}
【问题讨论】:
-
我的 index.html 中有 ,它是如何重复的?
-
其他建议呢?您在这里没有提供太多背景信息,如果没有所有事实,很难知道它可能是什么......
标签: css media-queries