开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜