Site on mobile not shrinking - mobile

I have a Drupal site where the site on mobile isn't shrinking. It was working fine a few days ago and when I logged in today to do more work, it isn't anymore. I can't seem to figure out why.
I've tried several options for the viewport and none have made a difference. It may be that I've just looked at this code for too long and I'm just missing something.
It's just the front page: http://inv3nt.tgci.com/home
The inner pages are still under construction as far as the theme and such goes, so they're all messed up right now.
Eventually the site will get its own mobile theme, but for now I need this one to scale appropriately on mobile devices. Wish I could figure out what changed in the last few days to make it not work when it was previously.
Thanks for any help you can give. :)

It looks like you have no responsive theming, you have also set a min-width on the page wrapper meaning the page can not go smaller than 1200px
#wrapper {
min-width: 1200px;
}
#main-content {
width: 1200px;
}
You will need to add some media queries http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
eg.
#media screen and (max-width: 1200px) {
#wrapper {
min-width: 100%;
}
#main-content {
width: 100%;
}
}
You will also need to fix other issues such as the header and where you have 2 or four column elements.
You should look at creating a mobile first theme for your site to avoid having to create multiple themes.
You should also look at implementing a mobile menu, I recommend https://www.drupal.org/project/responsive_menu although there is a small cost for commercial use of one of the scripts

Related

Is there a way to customize the number of pages being printed on JavaScript / React?

I am currently working on a React application that uses Chart.js. Recently, I have found a new bug when using Chrome: whenever I'm trying to print a page that contains the charts, over 600 additional blank pages are generated.
This happens whether I print using cmd + print or window.print().
It is important that people can print these reports on our application. This issue is currently happening on Chrome, but not on Safari.
Is there any way to set the number of pages being printed, either with CSS or JavaScript?
maybe some property on #media print ?
Your help will be greatly appreciated!
I investigated this issue further.
The v108 Google Chrome update brought issues on Print Preview for many users.
There is a workaround that involves applying this CSS:
.chartjs-size-monitor-expand > div {
position: fixed !important; // cannot stay “absolute”
}
chartjs-size-monitor,
.chartjs-size-monitor-shrink,
.chartjs-size-monitor-expand,
.chartjs-size-monitor-expand > div {
position: fixed !important; // cannot stay “absolute”
}
Source: Hundreds of blank pages and/or disproportion when printing a web page, after chrome version ~103 release (solved)
This fixed my issue! Hope it can help anyone who needs it.

How to conditionally load content (mobile-first)

I am about to create my first 'mobile-first' website and am unsure on the best way to conditionally load content as the viewport increases.
For example, lets say I wish to load a twitter feed only for desktop browsers, not mobile, how would I do this?
Option 1) Display: none - This is bad as content still loads for mobile
Option 2) Have content in markup, but remove.element with javascript - I believe this content still loads first, then is removed after? If so, not good.
Option 3) Using javascript, if viewport is wide enough, load content - This seems to be the recommended approach, from what i've read, but Is it a good idea to have markup in javascript? I am thinking about accessibility, semantics and seo.
Are there any other better solutions?
Any advice would be greatly appreciated.
You might want to check out Modernizr . It's easy to install and you can use it check for HTML5 support in a visitors browser, as well as the window width, for example:
if (Modernizr.mq('(min-width: 400px)')) {
/* do this for tablets and desktops */
}else{
/* do this for handhelds */
}
Good luck!
UPDATE
thanks, but then in that case would it not be better to do that straight with javascript - if (document.documentElement.clientWidth > 640)
You are right, for that specific instance of deciding whether or not to load a twitter feed, there probably isn't a big advantage of using my suggestion over your option 3. Thinking ahead though, with repsonsive design, mobile sites and now HTML5, the next questions you are going to come up against are how to customise the CSS for different viewpoints, or how to test if a visitor's browser supports a certain HTML5 feature.
You could certainly take a roll-your-own approach and write custom javascript for each case, or you could use Modernizr to test if the visitors browswer supports media queries, and if it doesn't load respond.js, or use Modernizr to test if the vistor's browser supports geolocation or html5 forms or certain video formats ..., and if it doesn't conditionally load a cross browser polyfill.
There are usually multiple ways of achieving the same goal, I'm strong on not reinventing the wheel ;)
Who says? Display:none; is one the best practices in showing and hiding elements for any specific viewport.
And one thing Adam, mark-up is the least downloadable stuff for each device, they have to process some other things if you hide element by Jquery or Javascript. Because sometimes small devices either don't support loading them or take extra time that's why they are visible.
But it has the pitfall for SEO purposes.
For SEO optimization along with hiding elements you can do one of these things with your CSS.
First,
#media screen and (max-width:480px) {
div {
position: absolute;
left: -9999em;
width: 0;
height: 0;
overflow: hidden;
}
}
But it was the less efective because Google Webmaster takes care all such hacks. And You may be blacklisted from being Google indexed.So You should use one of these modern methods to hide elements.
Second,
div {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
padding: 0 !important;
border: 0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
}
or, third,
div {
color:transparent;
text-indent:100%;
overflow:hidden;
white-space:no-wrap;
font:0/0 a;
text-shadow:none;
}

Foundation Zurb 3 Orbit Counter Numbers?

I have an Orbit slider in a Foundation 3 site, and I need to be able to show slide numbers, as in "slide 3 of 8".
I see no options for that in the docs, but looking at the _settings.scss file I see these items:
$orbitSlideNumBgColor: rgba(0,0,0,0.7);
$orbitSlideNumFontColor: #fff;
$orbitSlideNumPadding: 5px;
But there's no indication how to use them. Uncommenting them doesn't do anything. How to integrate with a given slider, or do I need to do my oen coding to create numbers?
Take a look at the jquery.foundation.orbit.js file ... Here all options are listed. You want to:
$("#slider").orbit({ slideNumber: true });
Agreed that should have been documented :)

mobile device resolution and browser viewport size

I got galaxy nexus with resolution is 720x1280. But when I call $(window).width() it just return 360px. Are there anyway to calculate value of $(window).width() on other devices? For an example, galaxy s 480x800? I need those values for my media queries:
#media only screen and (min-width: 360px){
body{
font-size: 62.5%;
}
}
I don't know if you're going to like my answer.. but here goes.
Forget about width (fixed widths at least), and make your website device-agnostic. Don't base your breakpoints on popular device resolutions, instead base them on your content. Keep stretching that browser window until you get that gut feeling that says "that doesn't look right" - that's your next breakpoint.
Keep it as fluid as you can and rely on relative units - even on your media query declaration.
I suggest giving this article by Chris Armstrong a read: http://www.alistapart.com/articles/the-infinite-grid/ (although ALA appears to be temporarily offline)

what will it take to allow media queries through HTMLPurifier + CSStidy

what would it take to allow media queries through HTMLPurifier + CSStidy?
In other words, I am using these libraries:
require_once 'inc_php_classes/htmlpurifier-4_4_0/library/HTMLPurifier.auto.php';
require_once 'inc_php_classes/csstidy-1_3/class.csstidy.php';
...to sanitize admin-user input before I save it to database.. for populating an external style sheet ... and so it happens that any input media queries are getting munged.. e.g. this:
#media only screen and (min-width: 600px) and (max-width: 939px) {
becomes
#media only screen and min-width 600px and max-width 939px {
..which breaks the media query, at least in Chrome 18/Mac.
The form/input is used for creating custom style sheets for trusted admin users.. and they need media queries.. but even though they are trusted, I do not want to just drop use of CSStidy.. because of the off chance an admin goes AWOL, not to mention I want to clean their newbie CSS errors.
Not sure, it's definitely not supported by vanilla HTML Purifier. It is reasonably plausible that CSSTidy does parse media selectors properly, so it's just a matter of teaching HTML Purifire not to strip them out.

Resources