用另一个类来否定一个类的css属性

idl*_*age 5 html css

我有这个:

<div class="style1 neg">
    <input type="submit" value="blah" />
</div>
Run Code Online (Sandbox Code Playgroud)

和css:

.style1 {
    float: left;
    margin-top: 25px;
}
.style1 .neg {
    margin-top: 0;
}
Run Code Online (Sandbox Code Playgroud)

我试图否定margin-top,但是当我在浏览器中检查元素时,'neg'样式似乎完全被忽略了.我该怎么做呢?

Exp*_*lls 15

空间, is the descendant selector. .style1 .neg选择一个.neg后代.style.你想用.style1.neg

文档:http://www.w3.org/TR/css3-selectors/#class-html

在行动:http://jsfiddle.net/dH7JJ/