Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's the approach that I've used in the past to share resources across Android and iOS: </p> <ul> <li><a href="http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/" rel="nofollow noreferrer">http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/</a></li> </ul> <p>You can use this exact technique to have a shared codebase, but also have platform-specific files. Just add a folder to the www directory (not the shared directory), and put your platform specific CSS files inside of it. <em>Note: in this approach, a subfolder of www is symlinked, not the parent of www.</em></p> <p>For having separate CSS files between device form factors it's a little bit more tricky...</p> <p>One option is to conditionally append &lt;style&gt; elements during application initialization using JavaScript. You can inspect the user agent and the window dimensions, and manually add a &lt;style&gt; element for the appropriate platform and form factor. However, user agent sniffing is generally discouraged b/c it can be easily broken, or fail if a new device category is introduced.</p> <p>Another option is to include everything and use CSS media queries.</p> <p>If you are using a universal binary (targets both phone and tablet form factors), then you have to include the phone and tablet CSS both in the app. You can use CSS media queries so that CSS styles are only applied to specific device form factors. So, wrap your tablet styles in a media query, and they will only be applied to the tablet form factor. </p> <p>You can read more about CSS media queries here: </p> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/CSS/Media_queries" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/CSS/Media_queries</a></li> </ul> <p>You can access predefined CSS media queries for common device form factors here:</p> <ul> <li><a href="https://stackoverflow.com/questions/6370690/media-queries-how-to-target-desktop-tablet-and-mobile">Media Queries: How to target desktop, tablet and mobile?</a></li> <li><a href="http://css-tricks.com/snippets/css/media-queries-for-standard-devices/" rel="nofollow noreferrer">http://css-tricks.com/snippets/css/media-queries-for-standard-devices/</a></li> </ul> <p>If you are not using a universal binary, you would need separate project environments for each device category. In each separate project, you could symlink to the shared codebase, with a static path to the CSS file.</p> <p>If you want to conditionally insert specific CSS files to specific project configurations, then you either need separate projects for each, or you need to write a script to do it for you.</p> <p>Hopefully that helps...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload