如何将两个跨度元素一个对齐到左侧,另一个对齐到右侧? [英] How do I align two span elements one to the left, the other one to the right?
本文介绍了如何将两个跨度元素一个对齐到左侧,另一个对齐到右侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个< 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>
都位于页面左侧(因此我不能使用固定位置)。
I want the first <span>
to be on the left of the page and the second <span>
to be on the right side, regardless of page width (so I can't use fixed positioning).
我可以使用什么CSS做到这一点?
What CSS can I use to do this?
推荐答案
css变量 float
用于定位元素。
The css variable float
is used to position your elements.
选项为:
float:left;
float:right;
float:none;
<span style="float:left;">©2012 XYZ Corp. All Rights Reserved.</span>
<span style="float:right;">Built with <a
这里是工作示例:
<span style="float:left; color: red;">©2012 XYZ Corp. All Rights Reserved.</span>
<span style="float:right; color: blue;">Built for example</span>
这篇关于如何将两个跨度元素一个对齐到左侧,另一个对齐到右侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文