<html>
<body>
<button onClick="toggle()">Click to Flip</button>
<div class="item-container">
<div class='item'>Item 1</div>
<div class='item'>Item 2</div>
<div class='item'>Item 3</div>
<div class='item'>Item 4</div>
</div>
</body>
</html>
.item-container {
display: flex;
}
div.item {
background: #283747;
color: white;
margin: 1rem;
flex: 1;
}
.flip {
flex-direction: column;
}
function toggle() {
const itemContainer = document.querySelector('.item-container');
itemContainer.classList.toggle('flip');
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.