Which alignment technique you use depends on your circumstances but the basic one is float: right;
(你使用哪种对齐技术取决于你的情况,但基本的是float: right;
)
: (:)
<input type="button" value="Click Me" style="float: right;">
You'll probably want to clear your floats though but that can be done with overflow:hidden
on the parent container or an explicit <div style="clear: both;"></div>
at the bottom of the container.
(您可能希望清除浮点数,但可以通过overflow:hidden
来完成overflow:hidden
在父容器上或容器底部的显式<div style="clear: both;"></div>
。)
For example: http://jsfiddle.net/ambiguous/8UvVg/
(例如: http : //jsfiddle.net/ambiguous/8UvVg/)
Floated elements are removed from the normal document flow so they can overflow their parent's boundary and mess up the parent's height, the clear:both
CSS takes care of that (as does overflow:hidden
).
(浮动元素从正常的文档流中移除,因此它们可以溢出它们的父级边界并弄乱父级的高度, clear:both
CSS都会处理它( overflow:hidden
)。)
Play around with the JSFiddle example I added to see how floating and clearing behave (you'll want to drop the overflow:hidden
first though). (使用我添加的JSFiddle示例来查看浮动和清除行为的方式(您将要删除overflow:hidden
尽管首先overflow:hidden
)。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…