开发者

Align an anchor inside a div to right

开发者 https://www.devze.com 2023-04-09 16:33 出处:网络
I really don\'t开发者_如何学C know how to do this. I tried: #menu-right div { position: fixed; text-align: 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

精彩评论

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