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 change it to:

.side { height:300px; width:550px; }

when the window height is less than 600px.

Thanks.

Answers:

Answer

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);
Answer

Its called a media query:

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.