Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code below that has 3 lines of divs the problem is that i'm trying to put the Red Fruits and Green Fruits divs side by side with spacing in between but nothing seems to work any help would be greatly appreciated.

What I have tried:

Here is my JSFiddle[^]
Posted
Updated 17-Jun-18 19:55pm

1 solution

To get two divs side by side, you can put them in left/right floating divs:

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html>
<head>
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="//#" />
</head>
<body>
  <div>
    <div style="float:left;width:calc(50% - 5px);">
      <h3 class="class center">Red Fruits</h3>
      <div id="redid" class="redclass wrappingflexbox"></div>
    </div>

    <div style="float:right;width:calc(50% - 5px)">
      <h3 class="class center">Green Fruits</h3>
      <div id="greenid" class="greenclass wrappingflexbox"></div>
    </div>
  </div>

  <div style="clear:both">
    <h3 class="center class">Suggested Fruits</h3>
    <div id="randomid" class="randomclass wrappingflexbox top"></div>
  </div>
</body>
</html>


With your center style, the fruits would all be on one line, which is probably not what you want. You'd probably want to wrap them:
.wrappingflexbox {
  display: flex;
  flex-wrap: wrap;
  justify-content: left;
}


Try it out here: JSFiddle[^]
 
Share this answer
 
Comments
Member 13863747 18-Jun-18 2:23am    
Thanks for the post but sorry i slightly changed my code and i tried you method it doesn't work can you take a look at my new codes? http://jsfiddle.net/c692p78e/1/
[no name] 18-Jun-18 2:25am    
You didn't copy the essential part, the float:left and float:right :)
Member 13863747 18-Jun-18 2:30am    
I added but it looks like this http://jsfiddle.net/c692p78e/2/
[no name] 18-Jun-18 2:36am    
Remove this from your panel: table-layout: fixed;height: 100%;width: 30%;
So: http://jsfiddle.net/856cpzjw/1/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900