Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negating the css property of one class with another

Tags:

html

css

I have this:

<div class="style1 neg">
    <input type="submit" value="blah" />
</div>

And the css:

.style1 {
    float: left;
    margin-top: 25px;
}
.style1 .neg {
    margin-top: 0;
}

I'm trying to negate margin-top, but when I inspect the element in the browser, the 'neg' style seems to be ignored completely. How would I do this properly?

like image 935
idlackage Avatar asked Sep 05 '13 20:09

idlackage


1 Answers

The space, , is the descendant selector. .style1 .neg selects a .neg that is a descendant of .style. You want to use .style1.neg

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

In action: http://jsfiddle.net/dH7JJ/

like image 50
Explosion Pills Avatar answered Sep 27 '22 23:09

Explosion Pills