All geek questions in one place
CSS - how to put a div on the right on another div?
<body> <div class="main-div"> <table id="gameboard-table"></table> </div> <div class="main-div"> Waiting for X players to join <div> Player 1 - </div> <div> Player 2 - </div> <div> Player 3 - </div> <div> Player 4 - </div> </div> </body> The first div has a table that is created dynamically, the second is static.
I tried to use
.main-div { float: left; } but divs are still one below the other.
Of course, I didnโt forget to include the CSS file in html :)
How can I solve it?
thanks!!!
+5
2 answers
Your float on the left should be on the child div main-div:
.main-div div { float: left; } Check out this JSFiddle:
Note that now, as your HTML is written, the text โPendingโ does not appear above them. You will need to wrap this in a separate element so that it appears above the div (I assume that the effect you need).
+2