Trying to create a page with 4 columns, each set at 25% width and 100% height. The challenge is resizing them when toggled to be hidden or visible.
The goal is for:
- 4 visible columns = each at 25% wide
- 3 visible columns = each at 33% wide
- and so on...
When I toggle the hidden columns to be visible again, they should adjust accordingly. Any suggestions or solutions?
I've included a code snippet below:
$("#button-column-1").click(function() {
$("#column-1").toggle(1500);
});
$("#button-column-2").click(function() {
$("#column-2").toggle(1500);
});
$("#button-column-3").click(function() {
$("#column-3").toggle(1500);
});
$("#button-column-4").click(function() {
$("#column-4").toggle(1500);
});
.column {
float: left;
height: 100vh;
width: 25%;
-webkit-box-shadow:inset 0px 0px 0px 1px black;
-moz-box-shadow:inset 0px 0px 0px 1px black;
box-shadow:inset 0px 0px 0px 1px black;
}
<html>
<head> </head>
<body>
<div id="button-container">
<button type="button" id="button-column-1">Column 1</button>
<button type="button" id="button-column-2">Column 2</button>
<button type="button" id="button-column-3">Column 3</button>
<button type="button" id="button-column-4">Column 4</button>
</div>
<div class="column" id="column-1">
1
</div>
<div class="column" id="column-2">
2
</div>
<div class="column" id="column-3">
3
</div>
<div class="column" id="column-4">
4
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>