CSS3媒体查询以特定设备为目标

时间:2013-01-17 14:44:02

标签: wordpress css3 responsive-design media-queries

我的基本CCS有自己的wordpress主题,现在我想让这个设计对下面提到的最常用的设备布局做出响应。我想在横向和纵向模式下定位所有苹果设备: -

blackberry(320x240),
iphone3 (320x480),
iphone4 (640x960),
iphone5 (640x1136),
ipad    (1024x768),
large desktop screen above 1280.

如何使用CSS3媒体查询编写CSS样式表来定位响应设备?

2 个答案:

答案 0 :(得分:5)

http://css-tricks.com/snippets/css/media-queries-for-standard-devices/ 这只是一个启动者。您可以在该博客上阅读有关媒体查询和其他响应式设计内容的更多信息。

以下是css代码示例:

/* 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 */
}

答案 1 :(得分:0)

使用媒体查询查看此链接 http://www.craigkunce.com/web.media-queries.html