tags:

views:

54

answers:

4

ive got one 4 links. i want them all in the same row. two of them in the center, and the other two in the right. ive wrapped them two and two, but i cant get it to work.

my css looks like this:

#links_center {

}
#links_right {
    float: right;

}

but it doesnt work. the right links are under the first two links. could someone help me here.

A: 

Here's one way to do it, with the assumption that your links are in a fixed width container. Keep in mind that this isn't the only way, just a quick solution that may work for you:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Links Test</title>

        <style type="text/css">
            #links_center {
                float: left;
                width: 600px;
            }

            #links_right {

            }
        </style>
    </head>
    <body>
        <div style="width: 800px">
            <div id="links_center">
                <a href="#">Link 1</a>
                <a href="#">Link 2</a>
            </div>

            <div id="links_right">
                <a href="#">Link 3</a>
                <a href="#">Link 4</a>
            </div>
        </div>
    </body>
</html>
Mike Robinson
A: 

float:right only works if the #links_right set comes before the #links_center set in the source code. Either rearrange the source code or use float:left on the center set and use padding/margins to place where you want.

Doug
i put them in reverse order and it works to have in same row but the problem is that the center links are not in center, they are pushed to the left from the center line. how do i center them in an easy way
weng
A: 

It might help to CSS a determined width because it sounds like there might not be enough over all width for them to line horizontally. Also try to float left instead. Another option is making a table.

Ralph The Mouf
<table> <tr> <td class="link"> Link One </td> <td class="link"> Link Two <td> <td class=""link"> Link Three </td> <td class="link"> Link Four </td> </tr></table>
Ralph The Mouf
depending on how big of a deal these links turn out to be, the table may be a nice fast option. it is a clean option if you aren't using it for any major structure. still, if it can be done with css, most likely "cleaner"
johnnietheblack
A: 

You could try to use a third , make them all 30-33%, and center the content of (and right-align the content of ).

Ralf MC