Meta Tags
<meta name="viewport" content="width=device-width, initial-scale=1.0">
The above means mobile or any other device will not scale my website automatically and will therefore see my page as I intend them to do so.
CSS Styling
/** Default Global CSS Styles are here. **/
@media screen and (max-width: 979px) {
/** At this point, my top navigation is too big **/
/** for the device width, therefore we switch **/
/** to the mobile version of the navigation. **/
}
@media screen and (min-width: 650px) and (max-width: 979px) {
/** As the width gets smaller the content gets **/
/** smaller so this is to resize even more. **/
}
@media screen and (max-width: 649px) {
/** This is the final, smallest width option **/
/** I currently have in place. **/
}
@media screen and (min-width: 980px) {
/** This is the main, non-mobile website view **/
}
JQuery
$(window).resize(function () {
var PageWidth = $('body').innerWidth();
if (PageWidth > 979) {
$('#TopNavList').show();
} else {
$('#TopNavList').hide();
}
$('#TopNavList').children("li").removeClass("active");
});
Due to having JQuery's slide and fade functions on my page, these implement inline css to my page upon being activated. All appears to be working how it should apart from when you replicate these steps:
- Open up my webpage
- Change your width slowly making it smaller
- Between the two menus, nothing shows.
I have been battling out with this all week, I personally believe it is due to some browsers media queries width reading the inner width (without scrollbar) and some just the entire width (with scrollbar) however I haven't got a clue how to resolve.