javascript - 在 976px 宽度之后添加/删除 CSS 样式?

标签 javascript jquery html css fullpage.js

/*Fade in effect & one pager*/
.fullpage-wrapper {
    width: 100%!important;
    transform: none!important;
}

.fp-section {
    width: 100%!important;
    position: absolute;
    left: 0;
    top: 0;
    visibility: hidden;
    opacity: 0;
    z-index: 0;
    transition: all .7s ease-in-out;
}

.fp-section.active {
    visibility: visible;
    opacity: 1;
    z-index: 1;
}
/* Remove transition when website is still loading */
body {display:none}
body[class*="fp-viewing-"] {display:block}

我想为移动用户删除宽度低于 976 像素的这些给定样式。我怎样才能在 javascript 或 jquery 中完成这个?也可以让 else 打开吗?

if ($(window).width() < 967) {
   *remove these styles but how?*
}
else {
   *keep them/or do nothing*
}

最佳答案

你可以只使用 css:

@media only screen and (min-width : 967px) {
    /*Your styles */
}

关于javascript - 在 976px 宽度之后添加/删除 CSS 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46873684/

相关文章:

html - 显示 :Table-Cell width issues

javascript - HTML 选择选项显示 future 12 个月

javascript - 如何使用小于和大于 javascript 的条件删除数组值

javascript - 使用 onmouseover 获取地址时出现问题

JQuery验证插件: valid() returns false for non-required fields

javascript - 如何获取没有 'this' 的元素的索引?

html - 多行按钮旁边的图标

javascript - 无法在 axios 上添加授权 header

javascript - Node.js错误: Can't set headers after they are sent

javascript - fancybox 无法在页面加载时打开