Tips for aligning a table and a chart side by side using HTML

I am having trouble arranging the chart table and data table in my HTML code. The chart is displayed above the table, making it difficult to see the full table clearly. How can I rearrange the elements to ensure both are visible properly?

<!doctype html>
<html lang="en">
    <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=2">

        <title> BATTERY VOLTAGE</title>
    </head>
    <body>

        <div class="container-fluid">
            <h1 class="mt-2 mb-3 text-center text-primary">BATTERY VOLTAGE</h1>
            <div class="card">
                <div class="card-header">
                    <div class="row">
                        <div class="col col-sm-9">Battery Voltage</div>
                        <div class="col col-sm-3">
                            <input type="text" id="daterange_textbox" class="form-control" readonly />
                        </div>
                    </div>
                </div>
                <div class="column">

                <div class="card-body">
                    <div class="table-responsive" >
                        <div class="chart-container pie-chart" "width:60%" >
                        <div border="1" 
                                      align="left" >
                            <canvas id="bar_chart" height="90"> </canvas>
                        </div>
                        </div>
                         <table class="column">

                        <table class="table table-striped table-bordered" id="order_table" style="width:40%" align="right">
                            <thead>
                                <tr>
                                    <th width="5%">Order Number</th>
                                    <th width="6%">Order Value</th>
                                    <th width="6%">Order Date</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
https://i.sstatic.net/f69rA.png

Answer №1

To align the chart and table side by side, you can use CSS to adjust the width and positioning of each element. Set the chart's width to 60% and the table's width to 40%. Then float both elements to the left and right respectively.

    <title> BATTERY VOLTAGE</title>
    
    <style>
        .chart-container {
            width: 60%;
            float: left;
        }
        .table-container {
            width: 40%;
            float: right;
        }
    </style>
</head>
<body>

    <div class="container-fluid">
        <h1 class="mt-2 mb-3 text-center text-primary">BATTERY VOLTAGE</h1>
        <div class="card">
            <div class="card-header">
                <div class="row">
                    <div class="col col-sm-9">Battery Voltage</div>
                    <div class="col col-sm-3">
                        <input type="text" id="daterange_textbox" class="form-control" readonly />
                    </div>
                </div>
            </div>
            <div class="column">

            <div class="card-body">
                <div class="chart-container pie-chart">
                    <div border="1" 
                                  align="left" >
                        <canvas id="bar_chart" height="90"> </canvas>
                    </div>
                </div>
                <div class="table-container">
                    <table class="table table-striped table-bordered" id="order_table">
                        <thead>
                            <tr>
                                <th width="5%">Order Number</th>
                                <th width="6%">Order Value</th>
                                <th width="6%">Order Date</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</body>

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

Experiencing a Django CSRF issue when using a plain HTML form

I've encountered an issue while setting up a raw HTML form for users to submit suggestions and save them to a database using the POST method. Despite following the Help section steps, I keep receiving a Forbidden (403) CSRF verification failed. Reques ...

Locate all elements by a segment of the identification attribute

Is it feasible to achieve the following: I possess a collection of divs, all having IDs that conclude with '_font', such as 'body_font', 'heading_font', 'tagline_font', and so on. Is there a method to retrieve thes ...

Gather information on LinkedIn connections

Looking to extract data from LinkedIn, specifically the connections of my own connections. I've successfully developed a Python script using BeautifulSoup and Selenium that is able to access the profiles of my connections and scrape their first 10 con ...

Triggering Angular's $broadcast within an ng-repeat causes repeated firing of events

In my AngularJS application, I have a situation where I am nesting forms inside an ng-repeat. The issue arises when a button within the repeat triggers a function that includes a $scope.$broadcast. While everything else in the function executes correctly, ...

Ways to pause the clock, once the designated time has run out in 'jQuery Countdown'

When the specified time has elapsed, I trigger an 'Ajax Request'. The issue arises when the time is up, causing the 'Ajax Request' to continue running every second. Here is my 'AJAX CODE': var startdate = '2017-05-15 ...

Make sure to add the node_modules/ directory before pushing to the gh-pages branch

Struggling to deploy my site on the gh-pages branch of Github... I must include the node_modules/ folder, but git won't let me add it for committing changes. I know it's intentional not to include dependencies during development, but for live dep ...

Challenges with synchronizing the scope of global arrays when reading JSON files into objects

I'm attempting to load a JSON file into a global array of objects. The code appears to be functioning correctly, however, I am encountering difficulty extracting the data from the Ajax $.getJSON call and storing it in the global variable. This issue c ...

How can you prevent JQuery AJAX from automatically redirecting after a successful form submission?

Encountered an issue with loading http://example.com/signup.ashx: The redirect from 'http://example.com/signup.ashx' to '' was blocked by the CORS policy. This is due to the absence of 'Access-Control-Allow-Origin' header on t ...

Preventing Error in D3 Updates Caused by Invalid Path Formats

I'm encountering a problem with the d3 tree layout while dynamically adding nodes. When I add a path symbol to the node based on its type, I receive an error message "invalid path format" during updates. Both the Enter and update methods utilize the ...

Issues with displaying data in Angular ChartJS are troubling users

Currently utilizing Angular 6, my goal is to incorporate a Chart.js line chart. Essentially, I am fetching two arrays from my API: one named weight_data and the other named weight_date, which I then utilize for the chart. After receiving the arrays from t ...

Creating a streamlined real-time application using the powerful combination of Django-swampdragon and AngularJS

Currently, I am using django-swampdragon along with angularjs to develop a simple Django application that displays website requests in real-time. While the Django part of the logic seems to be functioning correctly, I encounter issues when attempting to m ...

The useMediaQuery responsive JS media query should be used instead of calling the React Hook "useState" inside a callback

I am working on implementing responsive javascript media queries using the useMediaQuery function but I am encountering an issue. The error message I'm receiving is: Error message: "useState" cannot be called inside a callback. React Hooks ...

Emptying the trumbowyg editor within an Angular environment

I am currently experiencing issues with the trumbowyg editor in a project I'm working on. I am able to update the editor by changing its model but cannot seem to clear its content using $scope.editorModel = '';. For a more detailed explanati ...

The selection button's threshold

Welcome to my website design project! I have implemented image buttons for my web page and want to restrict the number of images a user can select. If a user tries to navigate away after selecting more than 3 images, I wish to display an alert message. Her ...

Obtain the script's event feedback from the WebView and transfer it to React Native

My HTML script is used to display a module, but I encountered an issue with the eventHandler not responding. How can I ensure that the eventHandler in Web View triggers responses? I am not receiving any logs for the onSuccess, onError, or onClose methods w ...

The perplexing discussion of DOM enclosures within the v8 engine

While studying the design of V8 API structure, I came across a useful document explaining the relationship between isolates, contexts, and more: Link to V8 Binding However, one paragraph in particular has left me confused: It mentions that for compatibili ...

What is the most efficient way to save a document in mongoose based on a specific user's

Is there a way to ensure that when saving a template, it is associated with the user id? I have added a reference to the templateSchema for the User. User.model.js var UserSchema = new mongoose.Schema({ _id: { type: String, required: true, index: {uniq ...

CKEditor4 plugins do not function properly when used with multiple instances within Vue Components

After developing a Vue component for rich text editing with CKEditor 4 on my website, I encountered an issue. When the component is first mounted, everything works perfectly including all default plugins. However, if another instance of the same component ...

USDC to ETH Swap on Uniswap

Every time I try to swap USDC for ETH using Uniswap and Ethers, I keep encountering errors. async function swapUsdcToEth(amount, walletAddress) { const usdc = await Fetcher.fetchTokenData(chainId, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'); ...

Encountering an issue when converting SVG to PNG with JS due to xlink:href

I am attempting to convert an svg file to png on the client side. I found some guidance online, you can check it out here. It seems to work well unless there is an image element within the svg that contains attributes like xlink:href. Here's the error ...