[英]How to “comment out” CSS code from JavaScript?
Obviously one can't actually comment out the code, but, how, from JavaScript, do I make the following piece of CSS seems as if it were commented out? 显然,实际上不能注释掉代码,但是,如何从JavaScript中使下面的CSS看起来好像被注释掉了呢? How do I uncomment it after? 之后如何取消注释?
.box:hover div.innercontent {
-webkit-transform: perspective(3000) translateZ(200px);
-moz-transform: scale(1.1);
-moz-perspective: 3000px;
transform: perspective(3000) translateZ(200px) ;
z-index: 90;
box-shadow:0 0 35px 5px black;
}
.box:hover div.innerlabel {
-webkit-transform: perspective(500) rotateX(5deg) translateZ(60px);
-moz-transform: rotateX(5deg) scale(1.1);
-moz-perspective: 500px;
transform: perspective(500) rotateX(5deg) translateZ(60px);
box-shadow:0 0 20px 8px white;
z-index: 100;
}
.box:hover div.labelwrapper {
z-index: 100;
}
Thanks 谢谢
If the CSS makes up the entirity of a CSS file, you can set the disabled
attribute on the <link/>
element to disable all the styles defined in it. 如果CSS组成了CSS文件的整个实体,则可以在<link/>
元素上设置disabled
属性,以禁用其中定义的所有样式。 This is probably the easiest way, especially when dealing with :hover
styles. 这可能是最简单的方法,尤其是在处理:hover
样式时。
I'll show you how to do one and you can use the same technique for the others: 我将向您展示如何做,其他人可以使用相同的技术:
$(".innercontent")
.addClass('.innercontent-dummy')
.removeClass('.innercontent');
Then to restore 然后还原
$(".innercontent-dummy")
.addClass('.innercontent')
.removeClass('.innercontent-dummy');
The 'dummy' class doesn't have to have any formatting; 'dummy'类不必具有任何格式。 you just need it as a placeholder to find the element if you want to restore the original class. 如果要还原原始类,则只需要它作为占位符即可找到元素。
I use a modifier class, like "active," to toggle the on-off state of elements. 我使用修饰符类(例如“ active”)来切换元素的开关状态。 Bootstrap does this with menus and other elements as well. Bootstrap也会通过菜单和其他元素来执行此操作。
For example: 例如:
CSS: CSS:
.box.active:hover div.innercontent {
-webkit-transform: perspective(3000) translateZ(200px);
-moz-transform: scale(1.1);
-moz-perspective: 3000px;
transform: perspective(3000) translateZ(200px) ;
z-index: 90;
box-shadow:0 0 35px 5px black;
}
.box.active:hover div.innerlabel {
-webkit-transform: perspective(500) rotateX(5deg) translateZ(60px);
-moz-transform: rotateX(5deg) scale(1.1);
-moz-perspective: 500px;
transform: perspective(500) rotateX(5deg) translateZ(60px);
box-shadow:0 0 20px 8px white;
z-index: 100;
}
.box.active:hover div.labelwrapper {
z-index: 100;
}
JavaScript: JavaScript:
$('.box').toggleClass('active');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.