html - CSS, nth-child doesn't work? -
i building form, crazy reason, nth-child doesn't work on input fields, seems. jsfiddle illustrate problem: http://jsfiddle.net/ngulp/. second input field shouldn't margin-right, does. why doesn't work? html:
<div class="block-inner"> <h1>blah</h1> <hr /> <input type="text" placeholder="voornaam" name="firstname" id="firstname" class="left" /> <input type="text" placeholder="achternaam" name="surname" id="surname" class="left" /> </div>
css:
input { width: 45%; margin-right: 10%; } input:nth-child(2){ margin-right: 0; }
you need use :nth-of-type(n)
, otherwise counter increments each element within .block-inner
2 inputs results in 3rd , 4th position.
Comments
Post a Comment