jQuery移动横向和纵向类
我已经开始使用 jquery 移动框架,但我似乎无法使用横向和纵向类来最小化样式。
文件说
HTML 元素始终具有“纵向”或“横向”类别,具体取决于浏览器或设备的方向。
所以我的印象是
要么是 foo
要么 <代码>foo
foo
还是h1.landscape { font-size:16px; }
和 h1.portrait { font-size:9px; }
似乎不起作用。
如果有人能对此有所启发,我们将不胜感激。
I've started using the jquery mobile framework yet I cannot seem to use the landscape and portrait classes to minipulate styles.
documentation says
The HTML element will always have a class of either "portrait" or "landscape", depending on the orientation of the browser or device.
so I am under the impression that <h1>foo</h1>
would either be <h1 class="landscape">foo</h1>
or <h1 class="portrait">foo</h1>
yet h1.landscape { font-size:16px; }
and h1.portrait { font-size:9px; }
doesn't seem to work.
If anyone could shine some light on this it would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好的。我决定看看发生了什么,并使用curl通过android视图获取源代码。
唯一具有横向或纵向类的元素是 html 标签。
我还注意到框架不会在轮换时自动切换类,因此我测试过的以下代码可以工作。
废弃上述有缺陷的内容。
使用 Tommi Laukkanen 的小标题 上面的脚本工作正常。
ok. I decided to see whats going on and used curl to get the source code via android view.
The only element that has the landscape or portrait class is the html tag.
I have also noticed that the framework does not auto switch the class on rotation so the following code which i've tested works.
scrap the above that has flaws.
using a liitle from Tommi Laukkanen's script the above works fine.
抱歉,但这已经过时了!
从 HTML5 开始,CSS3 中就有了 MediaQueries。
现在你可以在 CSS 中决定样式:
Sorry but that is out of date!
Since HTML5 you have in CSS3 MediaQueries.
Now you can decide the style in CSS:
纵向和横向类被添加到 html 元素(不是页面上的每个元素),因此您希望 css 选择器首先查找横向/纵向。以下作品:
The portrait and landscape classes are added to the html element (not every element on the page), so you want the css selector to look for the landscape/portrait first. The following works:
将其放入 lil 插件中
put this in a lil plugin
使用这个函数:
Use this function:
这是在不同设备上测试的完整工作版本(基于 Phil Jackson 代码):)
我确信 jQuery Mobile 曾经处理过这个问题,但是我有另一个基于屏幕方向的工作版本,但我认为这将是由于简单而更好...
这添加了纵向或横向类,您不需要将其硬编码到模板文件中:)
谢谢
Here is a fully working version (based on Phil Jackson code) tested on different devices :)
I'm sure jQuery Mobile used to handle this, however I've another working version which is based on screen orientation, however I think this would be better due to it simplicity...
This adds the portrait or landscape class, you don't need to hard-code that to your template file :)
Thanks