플렉스 사용 JavaScript의 속성을 사용하여 나머지 항목에 상대적인 항목 길이를 설정합니다. 다음 코드를 실행하여 flex를 구현할 수 있습니다. 자바스크립트가 있는 속성 -
예시
<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: 1px solid #000000;
width: 300px;
height: 400px;
display: flex;
}
</style>
</head>
<body>
<div id = "box">
<div style = "background-color:orange;">DIV1</div>
<div style = "background-color:blue;">DIV2</div>
<div style = "background-color:yellow;">DIV3</div>
</div>
<button onclick = "display()">Set</button>
<script>
function display() {
var a = document.getElementById("box");
var b = a.getElementsByTagName("DIV");
var j ;
for (j = 0; j < b.length; j++) {
b[j].style.flex = "1";
}
}
</script>
</body>
</html>