Jus*_*tin 11 css css-selectors less
我使用less,并试图让过去的输入有边距的10px.这是我所拥有的,但它不起作用,并且不在最后一个输入上应用margin-bottom.有什么想法吗?
input {
margin-bottom: 0px;
&:last-child {
margin-bottom: 10px;
}
}
Run Code Online (Sandbox Code Playgroud)
和HTML
<form id="auth-form">
<input id="ember367" class="ember-view ember-text-field" placeholder="Email" type="email" name="email">
<input id="ember368" class="ember-view ember-text-field" placeholder="Password" type="password" name="password">
<div class="clear"></div>
<a class="pull-left forgot-password">Forgot password?</a>
<button class="pull-right" data-ember-action="1" type="button">Sign In</button>
</form>
Run Code Online (Sandbox Code Playgroud)
Bol*_*ock 23
你的最后一个input不是最后一个孩子 - 那将是你的button.
使用:last-of-type替代选择的最后input:
input {
margin-bottom: 0px;
&:last-of-type {
margin-bottom: 10px;
}
}
Run Code Online (Sandbox Code Playgroud)