2

So i have a following structure in my html

<div container>
<div row>
  <div col-3></div>
  <div col-9>
    <div row>
       -<div col #problem here></div>
       -<div col #problem here></div>
     </div>
   </div> -closing column col-9
 </div> - closing row
</div> - closing container

As you can see i have one row nested inside another row, and then in that inside row i have two more columns (trying to divide that col-9 into more cols)

Problem is,for some reason the inside columns instead of being next to one another go underneath, and both act like they are col 12 in the row and take up the whole 100% of that col-9.

(Im trying to have input and button on the same line)

Thanks in advance

UPDATE: No, haha, i didn't forget the class attributes and how they work. I just didn't include them while typing the code here for the question. Like i said, its just the structure. or my code. If needed ill copy and paste the code exactly, but its quite lengthy

UPDATE CODE HERE:

<div class="container">
<div class="row">
    <!-- ####################################################### NAV BAR ###########################################################-->
    <div class="col col-md-3"> <!-- havbar div -->
        <ul class="nav nav-pills nav-stacked admin-menu">
            <li class="nav-item"><a class="nav-link active" id="home-tab" data-toggle="tab" onclick="openContent(event, 'home')" role="tab" aria-controls="home" aria-selected="true"><i class="fa fa-home fa-fw"></i>Home</a></li>
            <li class="nav-item"><a class="nav-link active" id="profile-tab" data-toggle="tab" onclick="openContent(event, 'profile')" role="tab" aria-controls="profile" aria-selected="false"><i class="fa fa-list-alt fa-fw"></i>Profile</a></li>
            <?php if ($super_admin == 1) echo '<li class="nav-item"><a class="nav-link active" id="addstaff-tab" data-toggle="tab" onclick="openContent(event, \'add_staff\')" role="tab" aria-controls="add_staff" aria-selected="false"><i class="fa fa-cogs fa-fw"></i>Add Staff Member</a></li>'?>
            <li class="nav-item"><a class="nav-link active" id="settings-tab" data-toggle="tab" onclick="openContent(event, 'settings')" role="tab" aria-controls="settings" aria-selected="false"><i class="fa fa-cogs fa-fw"></i>Settings</a></li>
            <li class="nav-item"><a href="logout.php" data-target-id="Logout"><i class="fa fa-cogs fa-fw"></i>Log Out</a></li>
        </ul>
    </div>
    <!-- END OF NAVBAR -->

    <div class="tab-content col-md-9 well admin-content"><!-- content div -->
        <!-- ######################################################3################# HOME CONTENT ########################################################################################-->
        <div id="home" class="tab_content">
            <?php echo "<h1>Welcome " . $_SESSION['firstName'] . "!</h1>"?>

            <div class="search">
                <!-- Displays a text box to search for participant -->
                <form action="">
                    <input type="text" id="participant" placeholder="Search for participant" onkeyup="showHint(this.value)">
                    <!--                    <div id="suggestions"></div>-->
                </form>
                <br><br>
                <!-- Displays possible participants (hints) -->
                <p>Suggestions: <span id="txtHint"></span></p>

                <script>
                    function showHint(str){
                        var xhttp;
                        if(str.length == 0){
                            document.getElementById("txtHint").innerHTML = "";
                            return;
                        }
                        xhttp = new XMLHttpRequest();
                        xhttp.onreadystatechange = function(){
                            if(xhttp.readyState == 4 && xhttp.status == 200){
                                document.getElementById("txtHint").innerHTML = xhttp.responseText;
                                // document.getElementById("suggestions").style.border="1px solid #A5ACB2";
                            }
                        };
                        xhttp.open("GET", "getparticipants.php?q=" + str, true);
                        xhttp.send();
                    }
                </script>
                <div class="col col-2"></div>
                <div class="col col-8 table_div"><table class="table">
                        <?php
                        //table header
                        echo '
                <thread>
                <tr>
                  <th scope="col" align="center">ID</th>
                  <th scope="col" align="center">Name</th>
                  <th scope="col" align="center">Email</th>
                </tr>
                </thread>
          <tbody>';

                        //Fetch and print all the records:
                        while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC))
                        {
                            echo
                                '<tr>
                    <td align="center">' . $row['id'] . '</td>
                    <td align="center"><a class="client_name" href="client_profile_overview.php">' . $row['name'] . '</a></td>
                    <td align="center">' . $row['email'] . '</td>
                    <td align="center"><button type="button" class="btn btn-default btn-sm view_profile_btn" id="view_profile_btn">View Profile</button></td>
                  </tr>';
                        }
                        //close the table and free up the resources.
                        echo '</tbody></table>';
                        ?>
                </div>
            </div>
        </div>
        <!-- ######################################################3################# PROFILE CONTENT ########################################################################################-->
        <div id="profile" class="tab_content">
            <h3>Profile</h3>
        </div>
        <!-- ######################################################3################# ADD STAFF CONTENT ########################################################################################-->
        <div id="add_staff" class="tab_content">
            <h3>Add Staff Member</h3>
            <p>Enter Staff ID Number to be added to the System.</p>
            <div class="row">
                <form action="" method="post">
                <div class="col col-5 float-left">
                    <input type="text" name="add_staff" id="staff_id_input" placeholder="New Staff ID">
                </div>
                <div class="col col-2 float-right">

                        <button class="btn btn-info" type="submit">Add</button>

                </div>
                </form>
            </div>

            </div>
        </div>
        <!-- ######################################################3################# Settings CONTENT ########################################################################################-->
        <div id="settings" class="tab_content">
            <h3>Settings</h3>
        </div>
    </div>
</div>

inside column

inside row

Main column (col-md-9)

Eddy
  • 61
  • 1
  • 2
  • 8
  • pretty sure thats bootstrap 4. The problem is in the div with the add_staff ID. Sorry should of specified that earlier. – Eddy Mar 22 '18 at 00:12
  • "content must be placed within columns and **only columns may be immediate children of rows**" -- you have .row > form > .col which won't work. – Carol Skelly Mar 22 '18 at 00:41
  • Not sure what you mean, content is within columns, always. And i just moved form outside and still didn't help. I will include a screen shot right now. – Eddy Mar 22 '18 at 00:45
  • Content in the cols is not the issue. the issue is that you have **a form directly inside a .row, and then the columns**... that won't work! Look at `div id="add_staff"` You should make the`
    ` and get rid of the `
    `.
    – Carol Skelly Mar 22 '18 at 00:49
  • Tried that just now, didn't help. Still same way as in the pictures i uploaded :( Anyway i can somehow bypass it by css? (I tried changing width %, but didn't help.) – Eddy Mar 22 '18 at 00:53
  • **LOOK**: https://www.codeply.com/go/nKSsb4FLbE – Carol Skelly Mar 22 '18 at 00:55
  • I kid you not, i just copied and pasted your code and it still shows the same thing. I feel like theres something wrong with my nesting – Eddy Mar 22 '18 at 01:03
  • Looks like the whole page is messed up.. I added a header and used columns in there as well, and a lot of them are also taking the length of the whole row. Footer same way. Not sure what the heck. – Eddy Mar 22 '18 at 20:19

3 Answers3

0

In your code I don't see .row class inside the content.

.row and .col are like tr and td in tables. Make sure you wrap your .cols with .row

Code works fine check the imported bootstrap files.

.b {
  border: 2px solid blue;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-3 b">3 - Left</div>
    <div class="col-9 b">
      <div class="row">
        <div class="col b">9 - Left</div>
        <div class="col b">9 - Right</div>
      </div>
    </div>
  </div>
</div>
Lahar Shah
  • 7,032
  • 4
  • 31
  • 39
-1

That problem is that you seem to have forgotten about your class attribute, and are instead trying to assign the classes as attributes themselves. As such, Bootstrap's class selectors won't apply, and your <div> will default to the standard of taking up 100% of the available width (thus stacking on top of each other).

To apply the classes, instead of <div col-3></div> (for example), you're looking for <div class="col-3"></div>. And don't forget to include Bootstrap's files themselves!

In terms of a full example, you're looking for:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<div class="container">
  <div class="row">
    <div class="col-3">3 - Left</div>
    <div class="col-9">
      <div class="row">
        <div class="col-6">9 - Left</div>
        <div class="col-6">9 - Right</div>
      </div>
    </div>
  </div>
</div>

I'd also recommend taking a look at the official examples as a starting point.

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
  • You don't need to do col-6, col-6 that's the point of using col only. – Lahar Shah Mar 21 '18 at 21:24
  • 1
    ^ This is true, though explicitly stating their width will help the OP understand that my example intends to have each section occupy 6 columns in this scenario. Not sure that explicitly stating their width should be worthy of a downvote though. – Obsidian Age Mar 21 '18 at 21:33
-1

IF Obsidian is wrong and you just used this 'syntax' as a shortcut, it just looks fine. So post your real code or check it for typos.

ejoo
  • 51
  • 1
  • 7