A Pen by Marc Ochsner on CodePen.
Created
March 29, 2021 17:16
-
-
Save mochsner/ba02683baed705c9c7dffb5303044e08 to your computer and use it in GitHub Desktop.
Flex Img Wrap
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 class="flex1"> | |
<div class="img"> | |
<img src="http://place-hold.it/432x324"/> | |
</div> | |
<div class="img"> | |
<img src="http://place-hold.it/432x324"/> | |
</div> | |
<div class="data"> | |
<div class="category"> | |
<div class="title"><h3>A title</h3></div> | |
<div class="box">length: 3.0 cm</div> | |
<div class="box">width: 3.0 cm</div> | |
<div class="box">depth: 3.0 cm</div> | |
<div class="box">surface area: 3.0 cm^2</div> | |
<div class="box">volume: 3.0 cm^3</div> | |
</div> | |
<div class="category"> | |
<div class="title"><h3>A title</h3></div> | |
<div class="box">length: 3.0 cm</div> | |
<div class="box">width: 3.0 cm</div> | |
<div class="box">depth: 3.0 cm</div> | |
<div class="box">surface area: 3.0 cm^2</div> | |
<div class="box">volume: 3.0 cm^3</div> | |
</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
.flex1 { | |
border: solid purple; | |
display: flex; // same as flex | |
flex-flow: row wrap; | |
// justify-content: flex-start; // default: flex-start | |
// align-content: normal; // default: normal | |
align-items: flex-start; | |
height: 50vh; | |
width: 80vw; | |
.img { | |
height:100%; | |
border: double; | |
border-color: red; | |
display:flex; | |
align-items: flex-start; | |
img { | |
object-fit: contain; | |
border: 1px solid #555; | |
} | |
// } | |
.data { | |
align-self: flex-end; | |
border: solid green; | |
display: flex; | |
flex-flow: row wrap; | |
flex: 0 2 auto; // default: grow 0, shrink 1, basis auto | |
.category { | |
border: dotted pink; | |
// flex: 0 2 auto; // 0 1 auto | |
// display: flex | |
// display: flex; | |
// align-items: flex-start; | |
// flex-flow: row wrap; | |
// border: solid orange; | |
// // display: flex; | |
// .box { | |
// // display: flex; | |
// } | |
} | |
.category2 { | |
display: flex; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment