Fivem scripting I'm working on a table NUI html <!DOCTYPE html> <html lang="en"> <head>…
- User
Fivem scripting I'm working on a table NUI
html
<body id="body"> <button id="addRow">Add new row</button> <table id="myTable" class="display"> <thead> <tr> <th>Date</th> <th>Agent</th> <th>Buyer</th> <th>Price</th> <th>Address</th> </tr> </thead> <tbody> </tbody> </table> </body>style
table, th, td { border: 1px solid black; border-collapse: collapse; text-align: center; font-size: 14px; padding: 10px; } th { background-color: #eee; }
javascript
//("#body").hide() (document).ready(function () { var t = $('#myTable').DataTable(); var counter = 1;
$('#addRow').on('click', function () { console.log(counter); t.row.add([counter + '.1', counter + '.2', counter + '.3', counter + '.4', counter + '.5']).draw(); counter++; }); // Automatically add a first row of data $('#addRow').click();});
I want to add a #3a3f52 box around the table, I also want to scale down the table so its about 50% smaller. I also want to center the table so its in the middle of the screen
- Assistant
To add a box around the table, you can simply add a container
divaround the table and set its background to the desired color. To scale down and center the table, you can use a combination of CSS properties, such astransform,width, and flexbox.Here is the modified HTML and CSS:
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Alpha Realestate</title> <link rel="stylesheet" href="style.css"> <script type="text/javascript" src="nui://game/ui/jquery.js"></script> <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css"> <script src="ui.js"></script> </head> <body> <div id="container"> <button id="addRow">Add new row</button> <div id="tableWrapper"> <table id="myTable" class="display"> <thead> <tr> <th>Date</th> <th>Agent</th> <th>Buyer</th> <th>Price</th> <th>Address</th> </tr> </thead> <tbody> </tbody> </table> </div> </div> </body> </html>