為什么父元素設置relative,子元素為absolute,定位卻根據body(body沒有設置position)
<div?class="login"> ?<div?class="log-input"> ??<input?type="text"?name=""><label>郵箱/手機號/用戶名</label> ??<input?type="password"?name=""><label>請輸入密碼</label> ?<div> ?<div> ??<i?class="square"></i> ??<span?class="next">下次自動登錄</span> ??<a?href=""?class="forget">忘記密碼?</a> ?</div> ?<div> ??<i?class="entry"></i> ??<i?class="register"></i> ?</div> </div>
.login?{ ?background:?#ebf3fa;? ?width:?250px; ?height:?350px; ?border:?1px?solid?#bbb; } .log-input?{ ?width:?200px; ?margin:0?auto;? ?} .log-input?input{ ?width:?200px; ?height:?30px; ????margin:5px?0; ????position:?relative;? } .log-input?label?{ ??color:?red; ??position:?absolute; ??top:?20px; ??z-index:?10; } .next?{ ?font-size:?14px; }
top:20px;不是根據input 來定位的
2017-03-20
二者不是父子關系,二者是兄弟關系啊。另外感覺你label標簽的用法也有點問題。。。