Skip to content Skip to sidebar Skip to footer

Put Element To The Right Side Of A Div

I'd like to know how I can put these divs to the right side of the White div. http://prntscr.com/5jmm6q As you can see, it stacks under the left div, and I want it to be to the upp

Solution 1:

Bit change in HTML

<divid="base"><sectionstyle="color: black;"><!-- added new div here --><divclass="leftMain"><divid="leftmenu"><divclass="titlebox"><divclass="text"><?phpecho NOM_SITE;?></div></div><ul><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li></ul></div><divid="leftmenu"><divclass="titlebox"><divclass="text">MENU</div></div><ul><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li></ul></div><divid="leftmenu"><divclass="titlebox"><divclass="text">MENU</div></div><ul><li><ahref="#">DATA</a></li></ul></div></div><divid="rightmenu"><divclass="titlebox"><divclass="text">MENU</div></div><divclass="droite_text"><li><ahref="forum.php?id=1">DATA</a></li></div></div><divid="rightmenu"><divclass="titlebox"><divclass="text">MENU</div></div><divclass="droite_text">
            DATA
            </div></div>

CSS changes

.leftMain{
     float:left;
    }
#rightmenu {
   float:right;
    }

http://jsfiddle.net/2oqbh17L/1/

Solution 2:

Here you can see the example.http://jsfiddle.net/fL5gg70o/

#leftmenu {float:left;
}

And for right div:

#rightmenu {float:right;
 }

Solution 3:

You should put everything You want to have on left to one container #left for example and add float: left to it. Everything You want to have on right put in #right and add float: right

Also You have some mistakes in code (for example many elements with #leftmenu id - id should be uniqe

here is fiddle http://jsfiddle.net/rwspycft/1/

Solution 4:

You would need to float those elements. However, if you float them they will flow out of the document flow. I'd try messing around with:

clear: both;

or/and

overflow: hidden;

http://jsfiddle.net/afgmyw4t/

Click the JSfiddle I have recreated your problem. I floated the elements left, and right. Then added clear:both; on the left elements to keep them within the document flow. They may need a few styling tweaks, if you have any trouble please leave a comment.

Solution 5:

You could wrap menus around separate div and set the float properties for both.

.rightt {
    float: right;
    vertical-align: text-top;
    margin: 0 auto;
    width: 50%;
}

.leftt {
    float: left;
    width: 50%;
}

<divid="base"><sectionstyle="color: black;"><divclass='leftt'><divid="leftmenu"><divclass="titlebox"><divclass="text"><?phpecho NOM_SITE;?></div></div><ul><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li></ul></div><divid="leftmenu"><divclass="titlebox"><divclass="text">MENU</div></div><ul><li><ahref="#">DATA</a></li><li><ahref="#">DATA</a></li></ul></div><divid="leftmenu"><divclass="titlebox"><divclass="text">MENU</div></div><ul><li><ahref="#">DATA</a></li></ul></div></div><divclass='rightt'><divid="rightmenu"><divclass="titlebox"><divclass="text">MENU</div></div><divclass="droite_text"><li><ahref="forum.php?id=1">DATA</a></li></div></div><divid="rightmenu"><divclass="titlebox"><divclass="text">MENU</div></div><divclass="droite_text">
            DATA
            </div></div></div>

FIDDLE

Post a Comment for "Put Element To The Right Side Of A Div"