如何将两个跨度元素左对齐,另一个向右对齐?

时间:2012-02-16 00:50:17

标签: html css

我有两个<span>元素:

<span style="margin-right:auto;">©2012 XYZ Corp. All Rights Reserved.</span>
<span style="margin-left:auto;">Built with <a href="http://www.wordpress.org/">Wordpress</a> and hosted by <a href="http://www.mediatemple.net/">(mt)</a> in California.</span>

我希望第一个<span>位于页面左侧,第二个<span>位于右侧,无论页面宽度如何(因此我无法使用固定定位)。

我可以用什么CSS来做这件事?

1 个答案:

答案 0 :(得分:25)

css变量float用于定位元素。

选项包括:

float:left;
float:right;
float:none;

<span style="float:left;">©2012 XYZ Corp. All Rights Reserved.</span>

<span style="float:right;">Built with <a href="http://www.wordpress.org/">Wordpress</a> and hosted by <a href="http://www.mediatemple.net/">(mt)</a> in California.</span>