Jak napisac w css lub js reguly typu:
Np div "ABC"
jesli div "ABC" ma height > 30 to wysokosc =300
jesli w div "ABC" pojawia sie scroll(overflow y) to wyskosc =300
var cw = $('.menu').height(); if (cw>100){ $('.menu').css({'width':'300px'}); }
var element = document.querySelector('.menu'); if( (element.offsetHeight < element.scrollHeight) || (element.offsetWidth < element.scrollWidth)){ // your element have overflow element.style.width = "300px"; element.style.background = "yellow"; } else{ //your element don't have overflow element.style.background = "red"; }
$( document ).ready(function() { var scrolled = false; $('nav.menu').on('scroll', function() { scrolled = true; $('nav.menu').css('width','280px'); }); });
$( document ).ready(function() { var scrolling = false; $('nav.menu').on('scroll', function(e){ if (!scrolling) { if ($('.menu').scrollTop){ $('nav.menu').css('width','280px'); } else{ $('nav.menu').css('width','none'); } } });