简体   繁体   English

jQuery if-request媒体查询的最大宽度

[英]jQuery if-request max-width for mediaqueries

I want to use if-requests for my jQuery-functions in my website for special window-widths. 我想在我的网站上对我的jQuery函数使用if-requests以获取特殊的窗口宽度。 This jQuery-functions enable and disable the attribute display of some divs and if the desktop is bigger than 1300pixels it should show all cols instead of only two in the same time. 此jQuery函数启用和禁用某些div的属性显示,如果桌面大于1300像素,则应同时显示所有列而不是仅显示两个列。 My jQuery functions look like this: 我的jQuery函数如下所示:

function changeCol() {
    var d1= document.getElementById('right-col');
    $(d1).removeClass('hidden');
    $(d1).fadeIn(200);
};

The CSS of the cols in 2cols mode are looking like this: 在2cols模式下的cols的CSS看起来像这样:

.col {
   float: left;
   margin-right: 1.36986301369863%;
   /*width: 31.50684931506849%;*/
   width: 47.93617021276596%;
   height: 100%;
   padding: 0 1.36986301369863%;
   overflow-y: auto;
   overflow-x: hidden;
}

width: 47.9% is the width for two displayed cols and width: 33.% for three displayed at the same time. width:47.9%是两个显示的列的宽度,width:33.%是同时显示的三个列。

You don't need jQuery for that at all. 您根本不需要jQuery。

Use CSS : 使用CSS

.right-col {
    width: 0;
    opacity: 0;

    -webkit-transition: opacity 200ms ease-out;
    -moz-transition: opacity 200ms ease-out;
    -ms-transition: opacity 200ms ease-out;
    -o-transition: opacity 200ms ease-out;
    transition: opacity 200ms ease-out;
}

@media only screen and (min-width: 1300px) {
    .right-col {
        width: auto;
        opacity: 1;
    }
}

That should preserve this fadeIn animation. 那应该保留这个fadeIn动画。

Here's a little fiddle that I prepared to show you the effect: http://jsfiddle.net/CgwDH/ . 我准备向您展示一下这种小提琴效果: http : //jsfiddle.net/CgwDH/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM