Last active
January 22, 2021 21:55
-
-
Save jmporchet/df48cb34477fc788b670f87f829aa6d5 to your computer and use it in GitHub Desktop.
How to hide HTML elements if there's not enough space to display them integrally
This file contains 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 type="text/css"> | |
.container { | |
width: 300px; | |
height: 200px; | |
display: flex; | |
/* put the undesirable elements on a second column */ | |
flex-flow: column wrap; | |
/* hide that second column */ | |
overflow: hidden; | |
} | |
.box { | |
width: 300px; | |
height: 75px; | |
} | |
.box:nth-child(1) { | |
background: red; | |
} | |
.box:nth-child(2) { | |
background: green; | |
} | |
.box:nth-child(3) { | |
background: blue; | |
} | |
</style> | |
<div class='container'> | |
<div class="box">shown</div> | |
<div class="box">shown</div> | |
<div class="box">hidden</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment