CSS在带有span的段落中左右浮动?
到目前为止,当我有一行包含
前一个 --- 页面宽度 --- 接下来的
示例时,我使用了一个带有 2 个子元素的容器 div,样式为 float:left & float:right
我认为它可以从一个带有 span 的段落行完成,可能是这样的:
<p><span class="s-left">previous</span><span class="s-right">next</span></p>
我尝试了 CSS with:
span.s-left { text-align: left; }
span.s-right { text-align: right; }
但这并没有做到。
Until now, when I had one line with example
previous --- page width --- next
I used a container div with 2 children, styled float:left & float:right
I am think it could be done from one paragraph line with span's maybe something like:
<p><span class="s-left">previous</span><span class="s-right">next</span></p>
I tried CSS with:
span.s-left { text-align: left; }
span.s-right { text-align: right; }
but that doesn't do it..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为
span
默认情况下显示为inline
,因此它没有定义要对齐的文本的宽度in(这是一个非常宽松的描述,但现在就可以了)。如果您想要左右对齐文本,这并不难,只需:
可以在 JS Bin
That's because
span
is by default displayedinline
, so it has no defined width for the text to be aligned in (that's a very loose description, but it'll do for now).If you want to have right and left aligned text it's not much harder, just:
A demonstration may be found at JS Bin