Is there a way to position a table to the left using bootstrap?

I've been struggling to align my table to the left side of my page using bootstrap with Flask. Despite numerous attempts, the tables remain centered and unaffected on the page as shown below.

{% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %}

<h1 align="center">Assist A Side</h1>

<div class="align-left-start">


<table class="table table-dark" name="Goalkeepers" id="tableStyle" align="right">
    <thead>
        <tr>
            <th scope="col">Name</th>
            <th scope="col">Positioning</th>
            <th scope="col">Handling</th>
            <th scope="col">Reflexes</th>
            <th scope="col">Average</th>
        </tr>

    </thead>
    <tbody>

        <tr>
            {% for gk in goalkeepers %}
            <td>{{ gk.gkName }}</td>
            <td>{{ gk.positioning }}</td>
            <td>{{ gk.handling }}</td>
            <td>{{ gk.reflexes }}</td>
            <td>{{ gk.average }}</td>
        </tr>
        {% endfor %}

    </tbody>
</table>

<table class="table table-dark" name="Outfield">
    <thead>
        <tr>
            <th scope="col">Name</th>
            <th scope="col">Defending</th>
            <th scope="col">Passing</th>
            <th scope="col">Dribbling</th>
            <th scope="col">Shooting</th>
            <th scope="col">Stamina</th>
            <th scope="col">Average</th>
        </tr>

    </thead>
    <tbody>
        <tr>
            {% for player in players %}
            <td>{{ player.name }}</td>
            <td>{{ player.defending }}</td>
            <td>{{ player.passing }}</td>
            <td>{{ player.dribbling }}</td>
            <td>{{ player.shooting }}</td>
            <td>{{ player.stamina }}</td>
            <td>{{ player.average }}</td>
        </tr>
        {% endfor %}

    </tbody>
</table>

</div>


{% endblock %}

Output

Expected

Answer №1

table {
  border-collapse: collapse;
  border: 1px solid black;
} 

th,td {
  border: 1px solid black;
}

table.a {
  table-layout: auto;
  width: 180px;  
}
<!DOCTYPE html>
<html>
<head>
<style>

</style>
</head>
<body>




<h1 align="center">Assist A Side</h1>

<div class="align-left-start">


<table class="a" name="Goalkeepers" id="tableStyle" >
    <thead>
        <tr>
            <th scope="col">Name</th>
            <th scope="col">Positioning</th>
            <th scope="col">Handling</th>
            <th scope="col">Reflexes</th>
            <th scope="col">Average</th>
        </tr>

    </thead>
    <tbody>

        <tr>
           
            <td>{{ gk.gkName }}</td>
            <td>{{ gk.positioning }}</td>
            <td>{{ gk.handling }}</td>
            <td>{{ gk.reflexes }}</td>
            <td>{{ gk.average }}</td>
        </tr>
       

    </tbody>
</table>

<br><br>

<table class="a" name="Outfield">
    <thead>
        <tr>
            <th scope="col">Name</th>
            <th scope="col">Defending</th>
            <th scope="col">Passing</th>
            <th scope="col">Dribbling</th>
            <th scope="col">Shooting</th>
            <th scope="col">Stamina</th>
            <th scope="col">Average</th>
        </tr>

    </thead>
    <tbody>
        <tr>
            
            <td>{{ player.name }}</td>
            <td>{{ player.defending }}</td>
            <td>{{ player.passing }}</td>
            <td>{{ player.dribbling }}</td>
            <td>{{ player.shooting }}</td>
            <td>{{ player.stamina }}</td>
            <td>{{ player.average }}</td>
        </tr>
       

    </tbody>
</table>

</div>



</body>
</html>

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

Learn how to change the input source in Ratchet's chat app to come from a text box on the webpage instead of the console

I followed the guidelines on to create a chat app. However, I now want to input data from a text box instead of using conn.send() in the console. How can I achieve this using php? I was successful in redirecting the sent message to an html element like ...

Adjust the size of the HTML input font to decrease as additional text is entered

Is it possible to create an HTML text field that automatically adjusts the font size when the user types more characters than it can display? I know Acrobat has this feature for forms, but I'm looking to implement it in HTML. So, imagine having a te ...

How can I position an element at the bottom of a page using VueJS and Bootstrap CSS?

https://i.sstatic.net/ojanG.png I am trying to move my footer (Copyright statement) to the bottom of the page. However, it is creating some extra white space beneath the footer. How can I eliminate this additional white space? This issue is occurring in ...

Creating a virtual roulette wheel with JavaScript

I'm currently working on creating a roulette wheel using JavaScript. While researching, I came across this example: , but I wasn't satisfied with the aesthetics. Considering that my roulette will only have a few options, I was thinking of using ...

Efficiently Minimize Bootstrap Components Upon Clicking the Link

I've successfully created a navigation menu that expands and collapses without using a dropdown feature. However, I'm encountering an issue where I can't seem to toggle the div when clicking on a menu link. I attempted to use JavaScript to c ...

Customize jQuery slideDown animation to have a specific height and handle overflow situations

Below is the HTML snippet I am working with: <div class="text">bla bla bla bla</div> <div class="button">Show</div> Here is the corresponding CSS: .text{ height:100px; overflow:hidden; } Imagine the .text div contain ...

Although PhoneGap resolution remains consistent, the outcomes may vary

I seem to be facing a similar issue as discussed in this post on Stack Overflow: Screen Resolution On A PhoneGap App My problem is that I have both an iPad and an Android tablet, both with a resolution of 1024 pixels across. However, while my screen displ ...

`Creating a fluid MySQL table using JavaScript`

One of the challenges I'm facing involves working with a MySQL table that consists of 3 columns: MySQL db table +--+----+-------------+ |id|data|display_order| +--+----+-------------+ |0 |0 |2 | +--+----+-------------+ |1 |1 |1 ...

Show the date and time in a visually appealing way by using HTML and JavaScript in an HTA application with scrolling effects

I have the following JavaScript code to show the current date in the format Mon Jun 2 17:54:28 UTC+0530 2014 within an HTA (HTML application). Now, I would like to display it as a welcoming message along with the current system date and time: Mon Jun 2 17: ...

What is the best method for deleting scripts to optimize for mobile responsiveness?

My current plugin.js file houses all my plugins for responsive design, but it is unnecessarily large and cumbersome for mobile devices. I am considering creating two separate plugin.js files to toggle between for mobile and desktop views. What are the r ...

Viewing at full width on mobile exceeds 100% [React]

I'm attempting to make a div cover exactly 100% of the width on mobile devices, but no more. The code I'm using is as follows: Here is my React code: <div className="max-width-100vw"> HELLO I AM A UNIQUE SENTENCE HERE??? </div> And ...

Transitioning the font stack from SCSS to JSS (cssinjs)

We are currently implementing a variety of custom fonts with different weights for various purposes. With our entire stack now using Material UI with JSS theming and styling, we aim to eliminate the remaining .scss files in our folder structure. All the f ...

Using jQuery to toggle the visibility of divs depending on the selection of multiple checkboxes

I found this code snippet that I need help with. <div class="row"> <div class="col-xs-4"> <label class="checkbox-inline"><input type="checkbox" value="draft">Draft</label> </div> <div class="c ...

Adding a Close Button to a MaterializeCSS Card or Card-Panel

Hey everyone! I'm looking for guidance on how to add a close button (x) to a card or card-panel in MaterializeCSS. While Bootstrap offers an Alert component, unfortunately MaterializeCSS does not have one readily available. Does anyone know of a wor ...

Using Javascript to place a form inside a table

When attempting to add a Form inside a Table, only the input tags are being inserted without the form tag itself. $(function () { var table = document.getElementById("transport"); var row = table.insertRow(0); var cell1 = row.insertCell(0); ...

What is the proper syntax for using .focus() with the nextElementSibling method in typing?

As I strive to programmatically shift focus in my form using nextElementSibling, I encounter a challenge with typing variables/constants due to working with Typescript... I have managed to achieve success without typing by implementing the following: myF ...

Substitute the <body> tag with a different tag

I am attempting to use the following code to replace the <body> tag on a page with <body id="khanqah"> echo str_replace("%body%", "khanqah", "<body id='%body%'>"); Although it adds <body id="khanqah"> to the page, the or ...

Calculate the total width of LI elements and apply it to the parent UL or DIV

Is there a way to calculate the Total LI width and then set the width for the parent div? Here is an example of my code: <ul> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds</li> <li>dsfdsfdsfds&l ...

How to utilize a specific option as a variable within a PHP select dropdown menu

In my PHP code, I am retrieving data from an Azure SQL database and using it to populate a drop-down menu with options. The SQL query I used returns two columns: Title and Cycle_ID. After setting the Title as the text string and Cycle_ID as the value for ...

The table's pagination displays above, thanks to Tailwindcss

I'm facing an issue where the pagination is showing up above the table, but I was expecting it to be displayed after the table. It would be ideal if the pagination appeared right after the table when adding multiple rows. Check this link for more inf ...