Align an anchor inside a div to right
I really don't开发者_如何学C know how to do this. I tried:
#menu-right div {
position: fixed;
text-align: right;
}
But this didn't work.
Perhaps it is because a
is not text. But how do I do this with text?
As I understand the problem this solution should work.
div#menu-right {
width: 100%;
position: fixed;
text-align: right;
}
jsfiddle
Css text-align property doesn't work on inline element like span, a . To align them you can just wrap them with another element like span. In stylesheet, Then select the wrapping element and simply use display: block; After adding this, the text-align property should work well. Write the code like below. In html:-
<span id="menu-right>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
</span>
<!--in the stylesheet write below code -->
<style>
#menu-right{
display: block; //or use width: 100%;
text-align: right;
}
</style>
精彩评论