Html 如何将我的链接与页面右侧对齐?

Html 如何将我的链接与页面右侧对齐?,html,css,Html,Css,我的索引页上有一个链接: <div class="content"> <a class="buy" href="buy.html">Buy</a> </div> 但它仍然位于左侧。(我已将CSS文件包含在我的index.html中,CSS文件已对页面上的其他元素生效)尝试float:right: a.buy { color: #2da1c1; font-size: small; text-decoration:

我的索引页上有一个链接:

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

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

尝试
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;         
}
(1) 您有
float:left
(2) 如果您添加
float:right
到div,它会有帮助吗?

尝试以下操作:

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

}
a.buy:hover
{
color: #f90;
text-decoration: underline;
}
您也可以尝试:

.content
{
    text-align: right;
}

您可能不需要
左:
。True。在我最初的回答后20秒,我把它移走了。通常,当你把东西向左移动时,它们会向左移动,而不是向右移动。
.content
{
    text-align: right;
}