Created
March 25, 2023 16:06
-
-
Save thecarlhall/37269fdfd63e1960d4847ca6014f944d to your computer and use it in GitHub Desktop.
Minimum html+css+javascript to have flex columns that will toggle focus on a selected column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<style> | |
.row { | |
display: flex; | |
} | |
.column { | |
flex-grow: 1; | |
border: 1px dashed black; | |
padding: 10px; | |
} | |
</style> | |
<script language="javascript"> | |
function toggle(sltr) { | |
const div = document.querySelector(`.column${sltr}`); | |
if (div.style['display'] == 'block') { | |
document.querySelectorAll('.column') | |
.forEach(el => el.style.removeProperty('display')); | |
} else { | |
div.style.setProperty('display', 'block'); | |
document.querySelectorAll(`.column:not(${sltr})`) | |
.forEach(el => el.style['display'] = 'none'); | |
} | |
} | |
</script> | |
<div class="row"> | |
<div class="column first"><a href="#" onclick="javascript:toggle('.first')">First Column</a></div> | |
<div class="column second"><a href="#" onclick="javascript:toggle('.second')">Second Column</a></div> | |
<div class="column third"><a href="#" onclick="javascript:toggle('.third')">Third Column</a></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment