I am making a responsive website. Here is fiddle:
http://jsfiddle.net/c6c99sbf/4/
I've made a few effects that fire when the window width is smaller than 768px, and some other effects that fire when the winddow width is wider than 768px. All works fine, except when I manually resize the browser window and pass the 768px breakpoint, either effects are not working properly, or layout gets broken.
For example, when you scroll down, you see the '+' button appears. I've coded so menu appears when you hover '+' button in the window width wider than 768px... In the window width smaller than 768px, menu should appear only when you click '+' button.
But when you view the page in the browser window size of 1200px, for instance, and manually resize it to 600px, + button still rotates on 'hover' and sidemenu appears on several clicks--thus click event not working properly. As soon as you refresh it, it works fine. All other effects that have to do with 768px breakpoint are not working properly.
I've googlged and searched the forum and tried them but with no luck. I also tried putting if (windowsize > 768) under $(window).scroll(function () { like this:
function checkWidth() {
var windowsize = $window.width();
$(window).scroll(function () {
if (windowsize > 768) {
var clicked = false;
if ($(window).scrollTop() >= 80 && clicked === false) {
$("#headerWrap").hide().css("position","fixed")
...
but it did not work either. What needs to be done? I've been trying to figure this out for last two days and totally exhausted now. Any help will be greatly appreciated!
!important
css attribute. It's a thing you should use as little as possible. You know css is cascading from top to bottom of your file, last lets say color added will be the color. Now jQuery is not writing in css file, it does those inline styles in the html tag which are always stronger then css styles. Now with!important
you can overwrite inline styles. Other way would be to remove.attr('style')
from JS – caramba