如何将我的链接对齐到页面的右侧? [英] How to align my link to the right side of the page?

查看:48
本文介绍了如何将我的链接对齐到页面的右侧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在索引页面上有一个链接:

I have a link on my index page:

<div class="content">
    <a class="buy" href="buy.html">Buy</a> 
</div>

我想将其对齐到页面右侧,

I would like to align it to the right side of my page, I tried:

a.buy{
  color: #2da1c1;
  font-size: small;
  text-decoration: none;
  left: 252px;
  float: left;

}
a.buy:hover
{
color: #f90;
text-decoration: underline;
left: 252px;
float: left;                 
}

但是它仍然位于左侧.(我已将我的CSS文件包含在index.html中,并且该CSS文件已对页面上的其他元素生效)

But it still located on the left side. (I have included my CSS file in my index.html, and the CSS file already take effect for other elements on the page)

推荐答案

尝试 float:right :

a.buy {
    color: #2da1c1;
    font-size: small;
    text-decoration: none;
    float: right;
}
a.buy:hover
{
    color: #f90;
    text-decoration: underline;         
}

另一种方式是:

.content {
    position: relative
}
a.buy {
    color: #2da1c1;
    font-size: small;
    text-decoration: none;
    position: absolute;
    right: 0;
}
a.buy:hover
{
    color: #f90;
    text-decoration: underline;         
}

这篇关于如何将我的链接对齐到页面的右侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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