如何在没有jquery元素的情况下重写css规则

how to rewrite the css rule without the element in jquery?

本文关键字:情况下 重写 css 规则 元素 jquery      更新时间:2023-09-26

我使用插件调用http://www.skitter-slider.net/带有jquery

我遇到了一个问题:

我想重写默认的img css样式:

.box_skitter .box_clone img {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
}

但我不能通过元素类、id等进行重写。

 $('.box_skitter .box_clone img').css({'width':w+'px','height':h+'px'});

因为插件将动态创建img元素,这意味着我为元素img 设置高度和宽度是没有效果的

那么解决方案是什么呢?

我想我找到了解决问题的方法:

$('head').append('<style>.box_skitter .box_clone img{width:'+w+'px !important;}</style>');