我想创建并排排列的div,每个填充高度和宽度的25%。我的脚本创建了25%的高度和宽度的div,但它们保持一个在另一个之下。我的脚本是:创建并排排列的div
function createDiv() {
var div_created = document.createElement("div");
div_created.setAttribute("class", "div1");
document.body.appendChild(div_created);
}
.div1 {
width: 50%;
height: 50%;
background-color: #000000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="estilo_segundo.css">
<body>
<button onclick="createDiv()">Click</button>
</body>
[如何将div并排排列]可能的副本(http://stackoverflow.com/questions/2637696/how-to-place-div-side-by-side) – Tibrogargan
'display:flex;' –
链接:-http://stackoverflow.com/questions/4938716/align-div-elements-side-by-side –