Is there a way to automatically position my canvas beside my table when there is enough space on the screen, and stack them underneath each other if the screen

I am facing an issue with aligning a table containing data and a chart visualizing this data using Chart.js. The chart is displayed in a "canvas" element and I can't seem to get them positioned next to each other.

I have tried implementing the following solutions:

  1. Using float:left property
  2. Placing both elements in the same div
  3. Applying column-count CSS property

Unfortunately, all of these attempts resulted in incorrect positioning. Float:left only partially aligns the graph with the table, placing them in the same div did not show any change, and column-count behaved similarly to float-left.

<script src="/Chart.js"></script>
<article>
<h2>my data</h2>
<table><caption>nice data</caption><thead>
<tr><th>some value</th><th>%</th><th>more values</th></tr></thead>
<tbody>
<tr><td>€ 100,00</td><td>17,59%</td><td>10 0 09 39 09 </td></tr>
<tr><td>€ 250,00</td><td>5,86%</td><td>0 79 7 35 5 </td></tr>
<tr><td>€ 10 000,00</td><td>5,48%</td><td>09 09 36 56 05 </td></tr>
<tr><td>€ 100 000,00</td><td>5,01%</td><td>79 35 85 94 03 </td></tr>
<tr><td>€ 107,50</td><td>4,11%</td><td>89 69 49 09 53 </td></tr>
<tr><td>€ 1 000,00</td><td>3,06%</td><td>28 06 15 51 20 </td></tr>
<tr><td>€ 2 500,00</td><td>2,79%</td><td>10 39 77 17 25 </td></tr>
</tbody></table>
<div style="height:80vh;"><canvas id="bedrag_perc"></canvas></div>
<script>
var ctx = document.getElementById("bedrag_perc");
var myChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: [100, 107, 250, 1000, 10000, 100000, 3.14],
        datasets: [{
            label: 'so much data',
            data: ['17.59', '4.11', '5.86', '3.06', '5.48', '5.01', '41.11'],
        }]
    },
    options: {
        animation: { duration: 0 },
        responsive: true,
        maintainAspectRatio: false
    }
});
</script> 
</article>

I aim to have the graph aligned next to the table on wider screens and stacked vertically underneath if the screen size is small (responsive design).

Currently, only half of the chart is appearing next to the table.

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

Is there a way to use jQuery to toggle a child element when the parent is clicked?

There are three images displayed on a webpage, each accompanied by a list of three events. The desired functionality is that when a user clicks on an event, the corresponding information should be displayed below that event. Below is the HTML structure: & ...

Ways to create distance between DIV elements?

On my WordPress generated page, I am looking to add AdSense below the header. You can view an image of the layout here. I have attempted to create space between the header and the AdSense ad by applying margin-top and padding to the div that contains the ...

How can I use AJAX to remove a record from a MySQL table?

I am looking to create a button with an image X that, when clicked, will delete a row from the database at that exact moment. teste-checkbox.php <style> table { font-family: verdana; font-size: 12px; } table th { text-align: left; backgrou ...

Creating Image Overlays with Hover Effects using CSS and PHP Conditions

Looking for some assistance with a Minecraft server listing page I am working on for a client. I have never done this before and have encountered a roadblock. Take a look at this image (apologies for using Paint, I was in a hurry!) The goal is to have the ...

What is the correct way to retrieve a JSON object instead of getting [Object object]?

Creating a basic web scraper integrated with mongoDB. Even though the API returns the JSON object in the correct format, when trying to append it to a bootstrap card on the page, I'm getting [Object object]. Below is my JavaScript code running on th ...

Using Angular JS to retrieve specific information from a JSON file

I am in the process of developing an AngularJS app that showcases notes. The notes are stored in a note.json file, and the main page of the app only displays a few fields for each note. I want to implement a feature where clicking on a specific note opens ...

Encountered a problem when attempting to access an element on a PHP page using

My javascript code is supposed to retrieve information from a specific URL (song.php) which contains the name of a song. However, there seems to be an issue as the javascript is not extracting the required data. Below is the HTML element and javascript fo ...

Utilizing window.matchMedia in Javascript to retain user selections during page transitions

I am encountering difficulties with the prefers-color-scheme feature and the logic I am attempting to implement. Specifically, I have a toggle on my website that allows users to override their preferred color scheme (black or light mode). However, I am fac ...

Tips for creating space between flex elements in Bootstrap without disrupting the layout breakpoints

<div class="row"> <div class="col-sm-6" style="margin-right: 1px;">CONTENT</div> <div class="col-sm-6"> CONTENT</div> </div> When adding a margin to the first element, it causes th ...

The inclusion of a CSS file via a link tag is malfunctioning when on the server

Here is my current folder structure: development{ core{index.php} css{index.css} } The document root in Apache is set to be development/core/. However, when I try to link the CSS file using a link tag with the path ../css/index.css, it doe ...

Access to the requested URL has been restricted. Flask is unable to process the method

I have been working on creating a dynamic web service for user login. Utilizing JavaScript, jQuery, and HTML, I aim to make the login process seamless and efficient. However, I have encountered an issue where, upon entering the correct username and passwor ...

Removing an item from a table row cannot be completed due to the inability to retrieve the list_body ID necessary for deletion

I have been working on enhancing the delete button function in my table. The id linked to the list_body must be incorporated into the delete function code. I utilized some jquery methods to render the list onto the webpage. //retrieve user list information ...

What is the proper way to specify the background image path in CSS?

My CSS file is located at: Project/Web/Support/Styles/file.css The image I want to use is found here: Project/Web/images/image.png I am attempting to include this image in my CSS file. I have tried the following methods: 1) background-image: url(/images ...

Having difficulty increasing the dimensions of the modal form text input field

I've been trying to adjust the size of the textboxes in a modal form by changing 'col-sm-20' to 'input-lg', but for some reason, it's not working. Can someone please help me figure out why? Thank you! <div class="form-gr ...

Inner div click events failing to trigger

When I move the .thumbnail divs outside of the #thumbhider and #thumbcontent divs, the click events function correctly. Currently, they are not working as expected. Website URL: I believe the issue may be related to the overflow:hidden property on the co ...

Guide to organizing a Bootstrap grid with 4 varying sizes of boxes

I'm just starting out with Bootstrap and I want to create a grid that resembles this design: https://i.sstatic.net/AQj53.png Below is the code I've written, but it's not quite giving me the layout I want: <!doctype html> <html> ...

Troubleshoot: Why Equal Height Columns in Bootstrap 4 are not functioning

My design includes two columns placed side by side, each containing different content. I assumed this was a default feature in Bootstrap 4 or at least in one of its alpha versions. I have attempted the following: .equal { display: -webkit-box; di ...

Tips on hiding specific table rows in two separate tables based on the chosen option from a dropdown menu

How do I hide table rows based on dropdown selection? The first table has a dropdown with two options: Current State and Future State. If I select Current State, I want to show or hide specific rows in the 2nd and 3rd tables. I am using IDs for these row ...

Implementing a function as the `data-*` attribute for an element in Angular 6

I have a question about my component.ts file: import { Component, OnInit, AfterViewInit, ElementRef, Inject } from '@angular/core'; import { DOCUMENT } from '@angular/platform-browser'; import { environment } from '../../../enviro ...

How to Handle Empty Input Data in JQuery Serialization

Having an issue with a form that triggers a modal window containing another form when a button is clicked. The second form includes an input field and send/cancel buttons. The goal is to serialize the data from the modal form and send it to a server using ...