A Pen by Laura Aubin on CodePen.
Created
November 9, 2018 10:18
-
-
Save t0nic/48ee6d4a3128e85667d71fc76c01d203 to your computer and use it in GitHub Desktop.
Flexy Dashboard Cards
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
<div id="container"> | |
<body onresize="windowSizeChanged()"> | |
<div class="card flexy"></div> | |
<div class="card flexy"></div> | |
<div class="card flexy"></div> | |
</div> |
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
function windowSizeChanged() { | |
allCards = document.getElementById("container").querySelectorAll(".card"); | |
firstCard = allCards[0]; | |
firstCard.classList.add("first"); | |
firstCardWidth = firstCard.offsetWidth; | |
lastCard = allCards[allCards.length - 1]; | |
lastCard.innerHTML = "Width: " + firstCardWidth; | |
lastCard.classList.remove("flexy"); | |
lastCard.style.width = firstCardWidth + "px"; | |
lastCard.style.backgroundColor = "skyBlue"; | |
return 0; | |
} | |
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
#container { | |
display: flex; | |
flex-wrap: wrap; | |
background-color: lightGrey; | |
padding: 10px; | |
max-width: 1500px; | |
} | |
.card { | |
background-color: teal; | |
margin: 25px; | |
height: 300px; | |
&:last-child { | |
// margin-right: 0; | |
} | |
} | |
.flexy { | |
flex-grow: 1; | |
min-width: 300px; | |
} | |
// important because the javascript is being overwritten | |
.first { | |
background-color: salmon !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment