19 Mar 2013 2:20 PM #1
Unanswered: Phone or tablet-specific style sheet
Using Sencha Touch, is it possible to load certain CSS files only when the device is a phone, or only when it's a tablet?
I know I can use the "x-phone" and "x-tablet" classes that are applied to the <body> tag, and I can use @media queries, but both of those require both style sheets to be loaded on either device. Since the device won't change once the app is loaded, I would prefer to just load one style sheet.
21 Mar 2013 5:45 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
Well you should be adding them to the app cache but there isn't a way to do that in app.json (in 2.2 you can for platforms but not profiles). So what you could do is add your own <link> element to the <head> dependent on which profile device belongs to.Mitchell Simoens @LikelyMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services firstname.lastname@example.org
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
21 Mar 2013 8:55 AM #3
Thanks. I think it would be a useful addition to Sencha Cmd, that it allow you to specify a "media" query for each CSS file. If there are files with different media queries, it could generate separate <link> tags for each query, and give them the appropriate "media" attribute.
18 Feb 2014 4:56 AM #4
Is this possible now ? Can we load stylesheets according to profiles that respect device, orientation etc ?