Why does everything seem to move in sync with the table's scrolling?

I recently had an issue resolved that fixed most of my concerns: I needed to make three separate edits, and now when I reintroduce the other two edits, they are included within the table section and scroll along with the table instead of being stuck beneath it.

The layout I'm aiming for is as follows:

-Header (APP Single Page App)

-Table of Users

-Page number and pagination

-Edit User -New User, side by side in two columns. I haven't been able to locate information on this specific type of question.

Here is how my CSS looks:

.my-custom-scrollbar {
  position: relative;
  height: 500px;
  overflow: auto;
}

.table-wrapper-scroll-y {
  display: block;
}

th {
  background: #67c8f5;
  position: sticky;
  top: 0px;
}

.table {
  border-collapse: separate;
}

This is my HTML structure:

<!DOCTYPE html>
<html lang="en">
    <head>
      <script type="text/javascript" src="myScript.js"></script>
      <link rel="stylesheet" type="text/css" href="style.css">
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
        <meta charset="utf-8">
        <title>Users</title>
        <meta name="description" content="APP Web Task 5">
        <meta name="author" content="SitePoint">
    </head>
    
    <!--Body content goes here-->
<body>
  <!--header-->

  <header class="container jumbotron text-center">
    <h2>APP Single Page App</h2>
  </header>

  <!--Section 1, table-->
  <div class="container">
    <section id="sectUsers">
      <div class="table-wrapper-scroll-y my-custom-scrollbar">
        <table id="tblUsers" class="table table-striped table-bordered table-fixed">
          <!--Table header-->
          <thead class="table table-bordered table-primary table-striped text-center">
            <tr id="tblUserHeader">
              <th scope="col">User ID</th>
              <th scope="col">Email</th>
              <th scope="col">First Name</th>
              <th scope="col">Last Name</th>
              <th scope="col">Avatar</th>
            </tr>
          </thead>
          
          <!--Table body-->
          <tbody class="table table-bordered">
            <tr id="user1">
              <td scope="row"><b>1</b></td>
              <td><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c5b59534e5b59125e504948547c4e594d4e594f125552">[email protected]</a></td>
              <td>George</td>
              <td class="w3-center">Bluth</td>
              <td>
                <div><img src="https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" alt="avatar" class="rounded-circle"></div>
              </td>
            </tr>

            <!-- Additional user rows go here -->

          </tbody>
      </div>
    </section>

    <nav aria-label="...">
      <ul class="pagination">
        <li class="page-item disabled">
          <a class="page-link" href="#" tabindex="-1">Previous</a>
        </li>
        <li class="page-item"><a class="page-link" href="#">1</a></li>
        <li class="page-item active">
          <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
        </li>
        <li class="page-item"><a class="page-link" href="#">3</a></li>
        <li class="page-item">
          <a class="page-link" href="#">Next</a>
        </li>
      </ul>
    </nav>


<!-- Section two, Edit User details -->
            <section id="sectUser" >
                <div >
                    <h2 >User</h2>
                    <div >
                        <img id="userAvatar" src="https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" alt="avatar">
                        <form id="frmUser" >
                            <label>User ID:</label>
                            <input type="text" id="userID">
                            <br>
                            <label>Email:</label>
                            <input type="text" id="userEmail">
                            <br>
                            <label>First Name:</label>
                            <input type="text" id="userFirstName">
                            <br>
                            <label>Last Name:</label>
                            <input type="text" id="userLastName">
                            <div >
                                <button id="btnSaveUser" >Save Changes</button>
                                <button id="btnDeleteUser" >Delete User</button>
                            </div>
                        </form>
                    </div>
                </div>
            </section>

<!-- Section three, Add new user form -->
            <section id="sectNewUser" >
                <div >
                    <h2 >New User</h2>
                    <div >
                        <form id="frmNewUser" >
                            <label>Username:</label>
                            <input type="text" id="userName">
                            <br>
                            <label>Job:</label>
                            <input type="text" id="userJob">
                            <br>
                            <div >
                                <button id="btnNewUser" >New User</button>
                            </div>
                        </form>
                    </div>
                </div>
            </section>
    </div>


    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90e0ffe0e0f5e2befae3d0a1bea1a6bea0">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    </body>
</html>

Answer №1

Ensure you properly close the </table> tag.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Clash of Form Action and JavaScript

Can someone help me with this issue? I have a form and a script to trigger an alert message. The code I'm using is working well: <input id="autocomplete" class="input_message" type="text" name="message" autocomplete="off" placeholder="...typ ...

Using shadow effects on the <Grid> component with Material UI

Is there a way to implement the box-shadow property on a <Grid> component in Material UI? I've gone through the official documentation regarding Shadows - Material UI, but I'm struggling to grasp how it can be applied to a <Grid>. De ...

Ajax displays JSON data within an array format

Looking for a solution where I have MySQL data displayed in a table, with each row having a button. When the button is clicked, a bootstrap modal should appear containing that data. I have converted the MySQL data to JSON format and assigned the ".view_dat ...

Securing uploaded documents and limiting access to approved individuals

Currently, I am utilizing Multer for file uploads and I am contemplating the ideal approach to secure access to these files post-upload. In my system, there are two user roles: admin and regular user. Users can only upload photos while only admins have ac ...

Showing undefined or null values in React and JavaScript

My goal is to format undefined or null values by italicizing them. If the value is an empty string, it should be displayed as is. If it has a value, that value should also be displayed as is. However, I am encountering an issue where null or undefined val ...

Arranging containers in a fixed position relative to their original placement

A unique challenge presents itself in the following code. I am attempting to keep panel-right in a fixed position similar to position: relative; however, changing from position: relative to position: fixed causes it to move to the right side while the left ...

The text alongside the radio button is not aligned vertically

Hello, I am attempting to vertically align text next to my radio button but encountering some issues. .radio { cursor: pointer; display: inline-flex; } .cui-a-radio-button__input { display: none; } .cui-a-radio-button__input:disabled + .cui-a-rad ...

Changing the shape of a background using CSS when hovering

My Bootstrap navigation has a unique setup, as shown below. I've observed that many users tend to only interact with the headings and ignore the submenus where the actual products are located. To address this issue, I want to change the design of th ...

Steps to insert a new row for a grid item using material-ui

When it comes to breaking a line of grid item like this, the image shown below illustrates how the rest space of the grid should be empty. https://i.stack.imgur.com/pvSwo.png <Grid container spacing={3} <Grid item xs={12}> "Grid Item xs ...

Looping through AJAX calls

Currently, I have a dataset that needs to be displayed on my webpage. Each item in the list has a unique identifier. Every item represents a bar and there is a corresponding document for bars that are visited by at least one user. If a bar has no visitors ...

The command "npm run build" is not running successfully, likely due to npm not being able to interpret ES6 syntax

I am currently developing a web application using Vue.js and Flask. While I can successfully compile the Vue app on my laptop by running npm run build and integrating the static files into my Flask app, I encounter an issue when attempting to do this on a ...

The jqueryMobile Dialog persistently opens during pageshow, despite having the cookie already set

My jQuery mobile dialog keeps opening every time the page is refreshed, despite having a cookie set to open it only once. I can't figure out why it's loading without any triggers. Any assistance would be greatly appreciated. JAVASCRIPT function ...

Utilizing the .data() method for establishing a variable

I am facing an issue while trying to set a variable in a form using .data(). The problem is that I cannot see any output for the variable "fee" - it just appears blank. What I am trying to achieve is for the user to select a Type, enter a footage, and then ...

Unique solution: "Using CSS to ensure the overflow document always scrolls to the bottom

Is there a way in CSS to make a div with overflow: scroll always automatically scroll to the bottom along the Y-axis, regardless of its content? For example, like a chat thread that consistently displays the latest message at the bottom. I've encount ...

Reactjs may have an undefined value for Object

I have already searched for the solution to this question on stackoverflow, but I am still confused. I tried using the same answer they provided but I am still getting an error. Can someone please help me resolve this issue? Thank you. const typeValue = [ ...

What is the best way to send a parameter to a Javascript .done callback from a .success method?

Is there a way to transfer information from a .success function to a done function? $.ajax({ url: "/Asgard/SetLanguagesElf", success: function () { var amount = 7; }, error: function () { alert("SetLanguagesElf"); }, type: &apo ...

What's the best way to capture an element screenshot using JavaScript?

I'm working on developing a unique gradient selection application. One of the exciting features I would like to incorporate is the ability for users to save their chosen gradients as digital images (.jpg format) directly onto their computers. When the ...

What's the trick to efficiently managing multiple checkboxes in an array state?

I have a lengthy collection of checkboxes that is not well optimized. I am trying to obtain the checked ones and store them in an array state. However, I am uncertain about how to handle this situation and I would appreciate some assistance. It should also ...

The use of event.returnValue is outdated and no longer supported. It is recommended to use the standard event.preventDefault() method instead. You may encounter

Hey there :) Currently, I am utilizing JQuery 1.9.1.js to search records using JSON. I am able to retrieve the search list locally, but when attempting to publish it on Windows Server 2008 and IIS 7, I face issues as it throws an error stating "event.ret ...

Troubleshooting a problem with CSS animations disappearing

I've been experimenting with CSS animations and I've run into a bit of a snag. I'm looking to create a div that fades in with a delay - meaning it won't be visible until the animation starts. Here's what I have so far: http://jsfi ...