Search field in DataTables appears to be misaligned


I'm in the process of developing a small website using JSP and DataTables (currently only for the first table).
Here's what I have so far:


As you can observe, there seems to be an alignment issue with the search field position. I'm not sure what's causing this problem. What I want is for the end of the search field to stay within the boundaries of the bottom table.
Here is my HTML code :

<TABLE class="table table-striped table-bordered" id="usertable" style="max-width: 800px">
<thead>
        <TR>
            <Th colspan=2 align=center><FONT color="blue">Toto</font><br>
                <i> (<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f1859e859eb1859e859edf9394">[email protected]</a>) </i><b><FONT color = "red">Administrator</b></font>
            </Th>
            <Th colspan=1 align=center><a href="UserUpdate?action=update&id=2">
                <button type="submit" class="btn btn-default"><FONT color="green"><span class ="glyphicon glyphicon-user">
                </span> Edit my account</FONT>
                </button></a>
            </Th>
        </TR>

        <TR>
            <Th width=40% align="center"><span class ="glyphicon glyphicon-calendar"></span> Fishing Date</Th>
            <Th width=40% align="center"><span class="glyphicon glyphicon-dashboard"></span> Fish Weight (Kg)</Th>
            <Th width=20% align="center"><i>Action</i></Th>
        </TR>
</thead>

<tbody>
        <TR>
            <TD width=40% align="center">03-07-2014</TD>
            <TD width=40% align="center">24.0</TD>
            <TD width=20% align=center><a href="FlightUpdate?action=delete&idvol=1">
                <button type="submit" class="btn btn-default" onclick="return confirm('Ok to delete the flight?')">
                <FONT color="purple"><span class="glyphicon glyphicon-trash"></span> Delete fishing trip</FONT>
                </button></a></TD>
        </TR>
        <TR>
            <TD width=40% align="center">22-08-2014</TD>
            <TD width=40% align="center">42.0</TD>
            <TD width=20% align=center><a href="FlightUpdate?action=delete&idvol=2">
                <button type="submit" class="btn btn-default" onclick="return confirm('Ok to delete the flight?')">
                <FONT color="purple"><span class="glyphicon glyphicon-trash"></span> Delete fishing trip</FONT>
                </button></a></TD>  
        </TR>
</tbody>
</TABLE>

And here is my JS selector :

<script>
$(document).ready(function() {
    $('#usertable').dataTable( {
        "dom": '<"top"fp<"clear">>rt'
    } );
      //$('.carousel').carousel();
});
</script>


Of course, I am utilizing JQuery libraries as well:

<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/jquery.dataTables.css">
<link rel="stylesheet" href="css/jquery.dataTables_themeroller.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>         
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>


Is there any suggestion on how to align sDom correctly?
Thank you very much!

Answer №1

The search bar in the data tables will stretch across the entire width of the screen, as demonstrated in your example with the viewport's full width. To rectify this issue, you must enclose the table within a wrapper element that defines the maximum width for the table to occupy.

<div style="max-width: 800px">
    <table class="table table-striped table-bordered" id="usertable" style="max-width: 800px">
     ........
    </table>
  </div>

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

Having trouble accessing the text in a paragraph using JavaScript executor and web driver

On a particular website, there is: <p id="tempid" value="Manual Effect">testing the test</p> String value = (String)((JavascriptExecutor) this).executeScript("return window.document.getElementById('tempid').value"); System.out.pr ...

Displaying decimal values in Angular as percentages

In my Angular application, I have a numeric textbox that displays a percentage value and allows users to update it. https://i.stack.imgur.com/eCOKe.png <label for="fees">Fees %</label> <div class="inpu ...

Proper utilization of ngIf in conjunction with mat-cell

I am attempting to show a specific value only if the item possesses a certain property, but I keep seeing [object Object] instead. Here is my current method: <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDe ...

Get all inputs with the same text using Vue 3 composition API and a single ref, or access multiple inputs with the

One of the challenges I'm facing is managing multiple instances of a component called InputWithValidation within a form. I need to check if all instances are valid at once. For a single instance of InputWithValidation, I can easily verify its validit ...

Using jQuery to combine the values of text inputs and checkboxes into a single array or string

I need to combine three different types of items into a single comma-separated string or array, which I plan to use later in a URL. Is there a way to merge these three types of data together into one string or array? An existing POST string User input f ...

The carousel comes to a halt once it reaches the final slide and does not continue cycling

Currently working on a website project for a client and utilizing Bootstrap to create a carousel feature. I am specifically using Bootstrap 3.0. After searching for a similar issue here, I found two cases that resemble mine but unfortunately have no soluti ...

I'm having trouble getting my button to work with addEventListener while using Ejs and Express. What could

Creating a Twitter-like platform where I can post tweets and have them display on the same page has been quite challenging. I've set up each post to have an Edit button initially hidden with 'display:none'. However, when I try to click on th ...

Tips for keeping certain webpages from showing up in Google search results

I recently launched a website that allows users to create their own profiles. The problem is, when someone links to their profile from their website or blog, it ends up showing in Google searches for my site. Unfortunately, the only person who has done thi ...

Tips on accessing the v-model value with a parameter in VUE

Looking to access the v-model value using a parameter, I attempted the following code: <template> <div v-for="(item, idx) in data"> <input :id="item" :v-model="item"></input> <button @click=&q ...

Deactivate the second subradio button when the first option is selected and vice versa

Need some assistance, hoping for your help. I have 2 choices with subcategories. 1 - Option A ---- variant 1 ---- variant 2 ---- variant 3 2 - Option B ---- variant 4 ---- variant 5 ---- variant 6 Check out my code here Users must choose betwe ...

What is the best way to verify the font-family using JavaScript?

To verify if the user has installed the font family, we can run a JavaScript function with AngularJS. I am using a Typekit font and have only loaded this service for users who do not have this specific font. ...

The format of the date cannot be modified when using DesktopDatePicker as a React Component

I've been attempting to modify the appearance of the component, but the UI keeps showing the date in month-year format. <DesktopDatePicker inputVariant="outlined" label="Pick-up date" id="date ...

What is the best way to add selected values from a multi-select dropdown into an array?

Attempting to populate an array from a multiple select dropdown, I've encountered an issue. Despite using splice to set the order of values being pushed into the array, they end up in a different order based on the selection in the dropdown. For insta ...

Utilize Bootstrap to align two images in the same row and adjust their sizes accordingly

I am looking to display 2 images side by side on a single row, with the ability for them to resize accordingly when adjusting the page size without shifting to another row. Currently, as I decrease the page size, the second image (the black block in the d ...

Updating the NPM entry point without relying on an index.js file

After successfully publishing a private module to NPM, which contains shared code used by multiple services, I encountered an issue with the transpilation process. Since the code is written in ES6, it needs to be transpiled using Babel before being publish ...

What sets & and &amp; apart in HTML5?

Can you explain the distinction between & and &amp;? In the code snippet below, do both symbols function in the same way? <a href="mailto:EMAIL?subject=BLABLABLA&body=http://URL, SHORT DESCRIPTION"></a> <a href="mailto:EMAIL?su ...

What could be causing jQuery to overlook the content within my div element?

I have a basic toggle feature for a div connected to a checkbox. $('#step2').hide(); $('#toggle-check').click(function(){ $('#step2').fadeToggle(); }) Why is .hide() not working to hide the contents of #step2? The content ...

Error encountered while using Jquery's .each() method on a DOM element and attempting to

Trying to utilize the each() function on my DOM to dynamically retrieve a field, I encountered an issue with the following code: var new_entry = new Object(); $('div[name="declaration-line-entry"]').each(function () { new_entry.name = $(this ...

Unable to execute JS script to navigate back to prior page with webdriver

Here is my code snippet: JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("window.history.go(-1);"); The code above isn't working. I've tried casting the webdriver instance but it doesn't work every time. I prefer not ...

In my opinion, CSS3 transform translateZ can be likened to scaling in some way

There are instances where I believe that the translateZ and scale properties produce similar effects, akin to zooming in or out. I suspect there is a mathematical relationship between them. If I know the value of one, such as translateZ(-1000px), along wi ...