Ryan
Ryan

Reputation: 5546

Align an anchor inside a div to right

I really don't 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?

Upvotes: 0

Views: 6414

Answers (2)

Encoder's YT
Encoder's YT

Reputation: 75

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>

Upvotes: 0

KryptoniteDove
KryptoniteDove

Reputation: 1268

As I understand the problem this solution should work.

div#menu-right {
    width: 100%;
    position: fixed;      
    text-align: right;
}

jsfiddle

Upvotes: 1

Related Questions