Hello, I am attempting to add a jquery table to my website. However, the overall theme I am using is conflicting with my table.
I believe the issues arise from the theme CSS .gh-content.gh-canvas.is-body
element.
The attempted solution I have tried using in the page HTML is to use overrides with important tags. However, my data is still compressed only to the center column of an invisibly columnated page.
How can I go about changing this?
Site Page: Market Data
HTML Ghost Page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Data Table</title>
<link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.dataTables.css">
<style>
:root {
--content-width: 800px;
}
.post {
width: 80%;
max-width: 1200px;
margin: 4rem auto;
padding-bottom: 4rem;
border-bottom: #EBF2F6 1px solid;
word-wrap: break-word;
}
#stock-table-container {
margin: 0 auto;
text-align: center;
}
#stock-table-container .dataTables_wrapper .dataTables_scrollHead th {
color: black;
white-space: nowrap;
text-align: center;
}
#stock-table tbody td {
white-space: nowrap;
text-align: center;
}
</style>
</head>
<body>
<div class="gh-content gh-canvas is-body" style="width: 100%; display: flex; justify-content: center;">
<div id="stock-table-container" style="width: 800px;">
<table id="stock-table" class="display" data-position="fixed">
<thead>
<tr>
<th>Country</th>
<th>Symbol</th>
<th>Company</th>
<th>Category</th>
<th>Price</th>
<th>Currency</th>
<th>Date</th>
<th>Change</th>
<th>Market Cap</th>
<th>Outstanding Shares</th>
<th>Volume</th>
</tr>
</thead>
<tbody>
<!-- Data will be dynamically inserted here -->
</tbody>
</table>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function () {
// Load CSV data
$.get('https://frontiermarketdata.com/assets/testdata', function (data) {
// Parse CSV data
var rows = data.split('\n');
for (var i = 1; i < 100; i++) { // Limiting to 100 rows for demonstration
var cols = rows[i].split(',');
$('#stock-table tbody').append('<tr><td>' + cols[0] + '</td><td>' + cols[1] + '</td><td>' + cols[2] + '</td><td>' + cols[3] + '</td><td>' + cols[4] + '</td><td>' + cols[5] + '</td><td>' + cols[6] + '</td><td>' + cols[7] + '</td><td>' + cols[8] + '</td><td>' + cols[9] + '</td><td>' + cols[10] + '</td></tr>');
}
// Initialize DataTable with fixed headers
$('#stock-table').DataTable({
"paging": false,
"searching": true,
"info": false,
"scrollX": true,
"scrollY": "300px",
"scrollCollapse": true,
"fixedHeader": true,
"autoWidth": true,
"columnDefs": [{
"width": "auto",
"targets": "_all"
}]
});
});
});
</script>
</body>
</html>