我需要将额外的“margin-top”应用于主体中的特定类。这个类的名字已经在一个CSS文件中记载:将样式应用于特定的主体类
html body.admin-menu {
margin-top:29px !important;
}
不过,我需要在我的jQuery的地方这边距更改为60像素。
我已经试过这4个选项没有雪茄:
$('html body.admin-menu').addClass('marginfix');
$('html body.admin-menu').attr('style', 'margin-top:60px !important');
$('html body.admin-menu').attr('style', function(i,s) { return s + 'margin-top: 60px !important;' });
$('<style>.marginfix { margin-top:60px !important; }</style>').appendTo('html body.admin-menu');
我似乎可以影响的唯一因素是“HTML”但我需要这种风格适用于这个非常特殊的情况下(HTML body.admin -menu),而不仅仅是“html”标签。
任何人都知道什么会工作?
感谢您的回复,但是,这似乎并没有工作。 – WebMW
你在浏览器控制台中是否有任何错误? – Jai
我很抱歉,它实际上是添加了类,(在控制台中没有错误),但是margin-top不适用于body。填充顶部的作品,但任何想法,为什么这可能是? – WebMW