我的索引页面上有一个链接:
<div class="content">
<a class="buy" href="buy.html">Buy</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我想将它对齐到我页面的右侧,我试过:
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;
}
Run Code Online (Sandbox Code Playgroud)
但它仍然位于左侧.(我已将我的CSS文件包含在我的index.html中,并且CSS文件已对页面上的其他元素生效)
thi*_*dot 24
试试float: right:
a.buy {
color: #2da1c1;
font-size: small;
text-decoration: none;
float: right;
}
a.buy:hover
{
color: #f90;
text-decoration: underline;
}
Run Code Online (Sandbox Code Playgroud)
另一种方式是:
.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;
}
Run Code Online (Sandbox Code Playgroud)