如何使一个WordPress页面在移动设备上显示不同

时间:2013-03-18 16:15:38

标签: wordpress

我有一个特定的WordPress页面,我需要在移动设备上查看时以更大的字体显示。我想过这样做:

@media handheld { /* rules for handheld devices */ }

...但是看不到我可以把它放到我页面的标题中。对我来说,最简单的方法是什么?

2 个答案:

答案 0 :(得分:0)

media =“only screen and(max-width:480px),only screen and(max-device-width:480px)”href =“/ assets / css / small-device.css”

http://mobile.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/

答案 1 :(得分:0)

如果你想在wordpress中定位特定页面,你可以这样做。

header.php 中的

添加此代码而不是开头的 <body> 标记

<body <?php $id = get_the_ID(); $title = str_replace(' ','-', strtolower(get_the_title($id)));  body_class($title); ?>>

这会得到页面的标题使其全部小写并添加破折号而不是空格。

所以,如果您有一个名为 The Neighborhood 的网页,那么您现在有一个名为 .the-neighborhood

的课程

在主 style.css

中将其定位
@media handheld { 
   body.the-neighborhood header {
      /*header styles for only the neighborhood page */
    }
}