简体   繁体   English

如何使用两个CSS文件设置一个HTML文件的样式?

[英]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.

相关问题 当我导入多个.scss 文件时,如何在 html 头中仅包含一个 CSS 文件? - How do i include only one CSS file in the html head when I import multiple .scss files? 如何将 CSS 和 js 文件捆绑到一个 HTML 文件中? - How do I bundle CSS and js files into a single HTML file? 使用JavaScript,如何根据另一个元素的CSS样式更改一个元素的CSS样式? - Using JavaScript, how do I change the CSS style of one element based on the CSS style of another element? 如何将 CSS 和 JS 文件链接到我的 github 页面的 HTML 文件? - How do I link CSS and JS files to my HTML file for github pages? 如何将一个 CSS 文件作为样式表连接到博客类型网站不同位置的多个 PHP 文件? - How do I connect one CSS file as a stylesheet to multiple PHP files in different places for a blog type website? 在一个HTML文件中使用多个CSS样式表 - Using More then one CSS style sheets in one html file 如何将一个 JavaScript 文件用于两个 HTML 文件? - How to use one JavaScript file for two HTML files? 我如何缓存特定文件html / css? - how do i cache specific files html / css? 如何禁用来自Aspx文件(HTML,CSS)的警告 - How do I disable warnings from Aspx files (HTML,CSS) 用一个 JavaScript 文件操作两个 html 文件 - Manipulating two html files with one JavaScript file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM