html – CSS新手:如何对齐我的链接到页面的右侧?
发布时间:2020-12-14 18:59:09 所属栏目:资源 来源:网络整理
导读:我的索引页面上有一个链接: div class="content" a class="buy" href="buy.html"Buy/a /div 我想把它放在我页面的右边,我试过: a.buy{ color: #2da1c1; font-size: small; text-decoration: none; left: 252px; float: left;}a.buy:hover{color: #f90;text
我的索引页面上有一个链接:
<div class="content"> <a class="buy" href="buy.html">Buy</a> </div> 我想把它放在我页面的右边,我试过: 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文件已经对页面上的其他元素生效了) 解决方法
尝试浮动:右:
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; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |