<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container{
width: auto;
display: flex;
align-items: flex-end;
background-color: red;
}
div{
width: 100px;
margin: 20px;
background-color: yellowgreen;
}
</style>
</head>
<body>
<script>
//让用户输入4个季度的数据
let data = []
for (let i = 0; i < 4; i ++) {
let num = +prompt(`请输入${i+1}季度的数据`)
data.push(num)
}
console.log(data)
//渲染柱形图
document.write(`<div class="container">`)
for (let i = 0; i < data.length; i ++) {
document.write(`
<div style="height:${data[i]}px;">
<p>第${i+1}季度</p>
<p>第${data[i]}</p>
</div>`)
}
document.write(`</div>`)
</script>
</body>
</html>