强制边距:0px到所有子元素,是否有可能?
问题描述:
是否可以强制行为并忽略子DIV中的css?强制边距:0px到所有子元素,是否有可能?
我想删除是一个顶级的DIV的孩子的所有利润......但仅此DIV童车
顺便说一句,我需要这个,因为我不能得到真正的CSS我需要注入的东西,取消行为(利润)我想擦除。
<DIV>
<DIV class="no_margin">
<DIV class="has_margin"> </DIV> // this one has a margin, and should lose it
</DIV>
</DIV>
<DIV class="has_margin"> </DIV> // should not lose margin
答
你可以做这些:
.no_margin .has_margin { margin: 0 }
.no_margin div { margin: 0 }
.no_margin * { margin: 0 }
而且你可以添加!important
如果优先级不够高,像margin: 0 !important
。
答
使用!重要
.no_margin *{
margin:0!important;
}
谢谢正是我需要的! –