我想創建並排排列的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 –