下面的代码创建了四个plotly.js表,并将它们放在另一个表下。
我希望代码或多或少保持原样,但要并排显示这四个表。我怎样才能做到这一点?
如下图所示,我尝试使用css'
float: left
但我一定是做错了,因为它不会改变任何东西。
<!DOCTYPE HTML>
<html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<style>
.side-by-side {
float: left;
}
</style>
<body>
<script>
var table_titles = [
'table 1',
'table 2',
'table 3',
'table 4',
]
function create_table(div) {
var data = [{
type: 'table',
header: {
values: [['header1'], ['header2']],
},
cells: {
values: [[1,2,3,4,5], ['a','b','c','d','e']],
}
}]
var layout = {
title: div.id,
}
Plotly.plot(div, data, layout)
}
function new_div(div_id) {
var div = document.createElement('div')
div.id = div_id
div.class = 'side-by-side'
return div
}
function create_tables() {
table_titles.forEach((title) => {
var div = new_div(title)
document.body.appendChild(div)
create_table(div)
})
}
create_tables()
</script>
</body>
</html>