[英]How do I style one HTML file with two CSS files?
I have to create two versions of a web app: one for landscape and one for portrait. 我必须创建两个版本的Web应用程序:一个用于横向,一个用于纵向。 But I need to run these both like we normally do in iPad;
但我需要像平常一样在iPad上运行这些; when in portrait mode, portrait version should work and if mode is landscape then the landscape version.
在纵向模式下,纵向版本应该工作,如果模式是横向,那么横向版本。
How can I make the site with one HTML file and two CSS files? 如何使用一个HTML文件和两个CSS文件创建网站?
use the css3 media query 使用css3媒体查询
/* 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 */
}
Look into responsive design. 研究响应式设计。 Twitter's Bootstrap project includes a series of responsive layouts, but the method is pretty basic: you define your CSS based on the current width of the device.
Twitter的Bootstrap项目包括一系列响应式布局,但该方法非常基础:您可以根据设备的当前宽度定义CSS。
http://twitter.github.com/bootstrap/scaffolding.html#responsive http://twitter.github.com/bootstrap/scaffolding.html#responsive
Here's an article explaining CSS3 and media queries: http://webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries 这是一篇解释CSS3和媒体查询的文章: http : //webdesignerwall.com/tutorials/responsive-design-with-css3-media-queries
Here are the css media queries
for Standard Devices :- 以下是标准设备的
css media queries
: -
/* 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 */
}
This one will help you 这个会帮助你
http://ajaxian.com/archives/iphone-windowonorientationchange-code http://ajaxian.com/archives/iphone-windowonorientationchange-code
It detects the orientation change of your browser and calls the java Script function . 它会检测浏览器的方向更改并调用java Script函数。 Inside the function you can load your css class as your preferance :)
在函数内部,你可以加载你的css类作为你的优势:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.