这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--mobile friendly-->
<meta name="viewport" content="width=device-width, user-scalable=yes">
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.css">
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
<style>
#container {
display:flex;
flex-wrap: wrap;
}
</style>
</head>
<body>
<div id="container" >
</div>
<script>
class App {
constructor() {
document.addEventListener("DOMContentLoaded", () => {
this.init()
})
}
init() {
var container = document.querySelector("#container")
$(container).width()
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
for (var i = 0; i < 50; i++) {
let el = $(`<div/>`);
el.css("background-color", getRandomColor())
el.width(Math.floor(100 + Math.random() * 100))
el.css("height", "20vh")
container.appendChild(el[0])
}
}
}
new App()
</script>
</body>
</html>
它的右侧有不相同的填充,但我希望它就像谷歌图像搜索页面(所有行左侧和右侧填充都是相同的),如何做
守着星空守着你
桃花长相依
胡子哥哥
相关分类