如何对齐文本中心和右 [英] how to align text center and right

查看:154
本文介绍了如何对齐文本中心和右的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对齐两个文本(一个在中心,另一个在右边)时遇到问题。

I am facing problem while aligning two text, one in center and other text in right.

我使用Div对齐它:

<div style="text-align:center">
  <h1> Sample Heading</h1>

    <div style="float:right; text-align:center">

         <a href="#">sample link</a> 

    </div>
</div>

当我使用时,我的标题是左,它不是一个中心对齐正确请告诉这是正确的方式或有任何其他方式来处理这种情况。

When I used this my heading comes left, its not a centrally align properly please tell is this the correct way or is there any other way to handle this scenario.

感谢

推荐答案

如果你想让项目不乱布局,尝试绝对:

If you want the item to not mess with the layout, try absolute:

<div id="header" style="position:relative;text-align:center;"><!-- define relative so child absolute's are based on this elements origin -->
    <div id="sampleLink" style="position:absolute; top:0px; right:0px; >Link</div>
    <h1 style="text-align:center;">Heading</h1>
</div>

这篇关于如何对齐文本中心和右的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆