【发布时间】:2013-01-20 03:09:48
【问题描述】:
这是我的代码(请看小提琴here):
<div class='container'>
<div class='hero-unit'>
<h2>Welcome</h2>
<p>Please log in</p>
<div id='login-box' class='pull-right control-group'>
<div class='clearfix'>
<input type='text' placeholder='Username' />
</div>
<div class='clearfix'>
<input type='password' placeholder='Password' />
</div>
<button type='button' class='btn btn-primary'>Log in</button>
</div>
</div>
</div>
我希望#login-box 拥有.pull-right 并与p 处于同一高度。我可以使用margin-top: -100px,但感觉不对。
如何在不硬编码否定的margin-top 的情况下让#login-box 与p 处于相同高度?
【问题讨论】:
-
只需删除您拥有的两个
class='clearfix',因为它们在那里不做任何事情,并将class='hero-unit'改为class='hero-unit clearfix'。
标签: html css twitter-bootstrap