Skip to content Skip to sidebar Skip to footer

Change Css Class If Window Is Less Than ()

How to change a properties of a CSS class in case when browser window is shorter than 600px. Default properties are following: .side { height:400px; width:700px; } I want to chang

Solution 1:

Its called a media query:

@media all and (max-height: 600px) {
    .side { height:300px; width:550px; }
}

Solution 2:

You could try :

(function($) {

    var $sides = $('.side');

    var setCss = function() {
        if($(window).height() > 600) {
            $sides.css('width', 400).css('height', 700);
        } else {
            $sides.css('width', 300).css('height', 550);
        }
    };

    $(document).ready(function() {
        setCss();
        $(window).resize(setCss);
    );

})(jQuery);

Post a Comment for "Change Css Class If Window Is Less Than ()"