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;
}
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)
Similarly, to right align a paragraph on the canvas with HTML's align attribute you could have: <P align="right">...
Give your links a display of "inline-block" and they will appear next to each other. You can then add some padding or margin to give them some space. You can achieve the same result by using the li tag and giving them the display:inline-block style.
If you want to move the button to the right, you can also place the button within a <div> element and add the text-align property with its "right" value to the "align-right" class of the <div>.
Try float: right
:
a.buy {
color: #2da1c1;
font-size: small;
text-decoration: none;
float: right;
}
a.buy:hover
{
color: #f90;
text-decoration: underline;
}
Another way would be:
.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) you have float: left;
on the example code
(2) maybe if you add float: right;
to the div it will help?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With