I've recently created a mobile version of my website. Generally things work fine, however I'm having some issues with mobile devices not scrolling horizontally on code snippets and with YouTube video embeds.
I use SyntaxHighlighter to highlight the code on the site, as per the code examples on the site. This works great for desktop viewers, however on mobile the code cannot be scrolled through horizontally (cutting off large portions of important code).
I use YouTube's iframe code to embed videos into article pages, however making the videos scale up and down correctly from desktop to mobile to fill the content container (or hit a maximum size) is proving difficult.
Any help on either of these problems would be greatly appreciated.
Where NNN is the max width you want the iframe to have, normally the container of the desktop version or even some size you want.
With this code, the width of the iframe will be 100% of it's container, unless the container is bigger than the max-width size you've setup. If it's bigger, the max-width will take place.
This will cover most of the problems and ensure the width is always the maximum the container can have, when screen size is smaller than the max-width value.
Since your container have overflow:hidden, the snippet is stretched but hidden due this CSS property.
The only way to actually simulate scrollbars is by using some javascript framework. The best one is Cubiq's iScroll 4 ( http://cubiq.org/iscroll-4 ) that have support to multiple touch events and other nice options.
This way, you can make the code snippets to accept touch events and then be scrolled horizontal, vertically or both.
The most common usage is:
Since you got lots of snippets (using the example you gave), you could apply some kind of loop for each of them, using a jQuery.each().
Let's make an example. Using jQuery and iScroll, you could make the following:
HTML:
CSS:
JS/jQUERY:
Since we need the iscrolls to take effect after the snippet highlighter has taken place, we can wrap the above code in a js function and add it as callback function at the snippet highlighter when it is done with the colors.
I think this will works. Made it now but the idea is right. Will test tonight and make the fixes if needed by editing the answer.
Well, i think that's it, feel free to ask if you don't understood a thing.
_*EDIT:*_
Fixed the JS code, added the codes for CSS and an the test-case HTML.
I've made a test-case
( http://portableideas.net/myRepo/trunk/stackoverflow/www/questions_7869572.html )