Above is a screenshot of how it looks on a 1920 width browser. This is essentially the layout I want, but when I resize the browser, it looks like this:
I would like the boxes to have no white spacing to the left and right of the individual sections and keep them all the same 100% width with/without the spacing.
I realize the spacing is occuring because of how the code is set up where the middle section has margin that pushes it away, but I'm not sure how to set this up to achieve both the first screenshot and this effect.
Fiddle: https://jsfiddle.net/jzhang172/r641pmzb/
body,
html {
margin: 0px;
font-family: lato-reg;
font-size: 16px;
color: #3c3c3c;
overflow-x: hidden;
}
img {
width: 100%;
height: 100%;
}
.section {
position: relative;
}
/*--------------------------------------Fifth Section--*/
.flex-container {
margin-top: 10px;
width: 100%;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.work-indiv {
width: 540px;
-webkit-flex: auto;
-ms-flex: auto;
flex: auto;
display: inline-block;
height: 237px;
position: relative;
margin-bottom: 10px;
cursor: pointer;
transition: 1s;
}
.work-indiv:hover img {
opacity: .6;
transition: .6s;
}
.middle {
padding-left: 10px;
padding-right: 10px;
width: 783px;
}
.work-indiv span {
position: absolute;
clear: both;
bottom: 0;
left: 0;
color: White;
margin-left: 40px;
text-transform: uppercase;
margin-bottom: 40px;
font-size: 2.125em;
font-family: latobold;
letter-spacing: .16em;
}
.middle span {
margin-left: 50px;
}
<div class="section" id="fifth">
<div class="flex-container">
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Topworkz">
<span>Topworkz</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Joint">
<span>Joint</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Market">
<span>Market</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Worktop">
<span>Worktop</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Lable">
<span>Lable</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="KYIV">
<span>KYIV</span>
</div>
</div>
Try removing the left and right padding on .middle in a media query for smaller screen sizes.
You have this in your code:
.middle {
padding-left: 10px;
padding-right: 10px;
width: 783px;
}
Try this adjustment:
#media screen and ( max-width: 1200px) {
.middle {
padding-left: 0;
padding-right: 0; }
}
Now, when the screen size is less than 1200px wide, the padding is removed.
Revised Demo
Change the padding of the elements to be always 5px.
Now, the separation between them is 10px, that is what you want.
To make the padding on the left most elements appear to be zero again, set a negative margin of -5px on the flex container. This will make the illusion that the elements are alligned perfectly
body,
html {
margin: 0px;
font-family: lato-reg;
font-size: 16px;
color: #3c3c3c;
overflow-x: hidden;
}
img {
width: 100%;
height: 100%;
}
.section {
position: relative;
}
/*--------------------------------------Fifth Section--*/
.flex-container {
margin-top: 10px;
width: 100%;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-left: -5px;
margin-right: -5px;
}
.work-indiv {
width: 540px;
-webkit-flex: auto;
-ms-flex: auto;
flex: auto;
display: inline-block;
height: 237px;
position: relative;
margin-bottom: 10px;
cursor: pointer;
transition: 1s;
padding-left: 5px;
padding-right: 5px;
}
.work-indiv:hover img {
opacity: .6;
transition: .6s;
}
.middle {
width: 783px;
}
.work-indiv span {
position: absolute;
clear: both;
bottom: 0;
left: 0;
color: White;
margin-left: 40px;
text-transform: uppercase;
margin-bottom: 40px;
font-size: 2.125em;
font-family: latobold;
letter-spacing: .16em;
}
.middle span {
margin-left: 50px;
}
<div class="section" id="fifth">
<div class="flex-container">
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Topworkz">
<span>Topworkz</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Joint">
<span>Joint</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Market">
<span>Market</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Worktop">
<span>Worktop</span>
</div>
<div class="work-indiv middle">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="Lable">
<span>Lable</span>
</div>
<div class="work-indiv">
<img src="https://pixabay.com/static/uploads/photo/2015/12/21/06/41/landscape-1102117_960_720.jpg" alt="KYIV">
<span>KYIV</span>
</div>
</div>
Related
So I have flexbox items inside of a flex container, inside of these items there are image and button as shown in the following picture:
But for some reason when I try to do that, the button goes above the image as per the below screenshot:
My css code:
.navbar .ps_container{ /*flex container*/
justify-content: space-between;
display: flex;
flex-wrap: wrap;
width:100%;
height: auto;
background-color: blue;
padding-bottom: 50px;
padding-top: 50px;
}
.ps_container>div{ /* flexbox items*/
display: flex;
flex:1 1 auto;
justify-content: center;
margin:20px;
padding-inline: 40px;
width:200px;
height:200px;
background-color: white;
}
.ps_container>div img{ /* image style*/
max-height: 300px;
max-width: 300px;
object-fit: contain;
vertical-align: middle;
margin: 0 auto;
}
.ps_container>div a{ /* button style*/
background-color: #20d8da;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
position: relative;
z-index: 1;
display: inline-block;
min-width: 160px;
height: 50px;
color: #fff;
border-radius: 0;
padding: 0 30px;
font-size: 14px;
line-height: 50px;
font-weight: 500;
text-transform: capitalize;
text-align: center;
}
<div class="ps_container">
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
</div>
I thought maybe it has to do with img not being display:block, but adding that didnt seem to work either.
I guess you are searching for flex-direction:column; in your div.block.
Doc : https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
After your block goes on each other because you are setting container size (200x200) smaller than img (300x300) inside it...
DEMO:
.navbar .ps_container{ /*flex container*/
justify-content: space-between;
display: flex;
flex-wrap: wrap;
width:100%;
height: auto;
background-color: blue;
padding-bottom: 50px;
padding-top: 50px;
}
.ps_container>div{ /* flexbox items*/
display: flex;
flex-direction:column; /***** ADDED *****/
flex:1 1 auto;
justify-content: center;
margin:20px;
padding-inline: 40px;
width:200px;
height:200px;
background-color: white;
}
.ps_container>div img{ /* image style*/
max-height: 300px;
max-width: 300px;
object-fit: contain;
vertical-align: middle;
margin: 0 auto;
}
.ps_container>div a{ /* button style*/
background-color: #20d8da;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
position: relative;
z-index: 1;
display: inline-block;
min-width: 160px;
height: 50px;
color: #fff;
border-radius: 0;
padding: 0 30px;
font-size: 14px;
line-height: 50px;
font-weight: 500;
text-transform: capitalize;
text-align: center;
}
<div class="ps_container">
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff">
view Games
</div>
</div>
You might wanna use flex-direction: column to achieve it.
.ps_container {
/*flex container*/
justify-content: space-between;
display: flex;
flex-wrap: wrap;
width: 100%;
height: auto;
background-color: blue;
padding-bottom: 50px;
padding-top: 50px;
}
.ps_container > div {
/* flexbox items*/
display: inline-flex;
flex-direction: column;
justify-content: center;
height: 200px;
background-color: white;
}
.ps_container > div img {
/* image style*/
max-height: 300px;
max-width: 300px;
object-fit: contain;
vertical-align: middle;
margin: 0 auto;
}
.ps_container > div a {
/* button style*/
background-color: #20d8da;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
position: relative;
z-index: 1;
display: inline-block;
height: 50px;
color: #fff;
border-radius: 0;
padding: 0 30px;
font-size: 14px;
line-height: 50px;
font-weight: 500;
text-transform: capitalize;
text-align: center;
}
<div class="ps_container">
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff" />
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff" />
view Games
</div>
<div class="block">
<img src="https://dummyimage.com/600x400/000/fff" />
view Games
</div>
</div>
EDIT
Updated the answer including the fix to the parent to wrap the boxes in a single row.
Changes I done:
Added flex-direction: column to the box .ps_container > div so that the button will come below the image.
Remove width:200px; from .ps_container>div.
Replaced display: flex with display: inline-flex in .ps_container>div.
By giving width in static, you will have to readjust the same when you are using the site in responsive mode, without that, the width and details will update according to the window width, and that's what I will prefer.
I have met some problems while doing a image-viewer project. The problem is that my buttons and the image are not following justify-content property, which they don't distributed equally inside my div block, how could it be solved? Also the image is not centered as the title does despite I set the align item property. I dow know how to fix that. I've searched over the website for solutions but none of them seems working.
Could anyone help me, please? Thanks in advance.
Here are the html and css code:
<div class="image-viewer__container">
<div class="image-viewer__title">Image Viewer</div>
<div class="image-viewer__main">
<div class="image-viewer__button"><img src="./images/back.png" id="previous" /></div>
<div class="image-viewer__display" style="background-image: url(./images/loading.gif);background-repeat: no-repeat; background-position: center;">
<img src="https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF" id="display">
<div class="image-viewer__display-source-wrapper">
<span><a href="https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF" target="_blank">
https://scontent.ftpe7-2.fna.fbcdn.net/v/t1.0-0/p640x640/119893827_3212042898922322_5684339818610522875_o.jpg?_nc_cat=104&_nc_sid=730e14&_nc_ohc=fGG3wRqLaLEAX8MrIY-&_nc_ht=scontent.ftpe7-2.fna&tp=6&oh=36c5e163223a1e8abca79a2b3892c915&oe=5F976AFF</a>
</span>
</div>
</div>
<div class="image-viewer__button"><img src="./images/next.png" id="next" /></div>
</div>
</div>
.image-viewer__container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-evenly;
}
.image-viewer__title {
font-size: 5rem;
font-weight: 600;
color: #615dec;
margin: 0;
margin-top: 2rem;
}
.image-viewer__main {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin: auto;
}
.image-viewer__button {
display: inline;
background: none;
border: none;
border-radius: 50%;
}
.image-viewer__button img {
width: 80px;
height: 80px;
border: 1px solid transparent;
border-radius: 50%;
cursor: pointer;
}
.image-viewer__display {
position: relative;
padding: 15px;
margin: 3rem;
max-width: 80rem;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
font-size: 0.6rem;
}
.image-viewer__display-source-wrapper {
position: absolute;
font-size: 12px;
left: 50%;
margin-right: 50%;
transform: translate(-50%, -50%);
min-width: 100em;
text-align: center;
bottom: 0;
}
#display {
object-fit: contain;
width: 50rem;
height: 30rem;
margin-bottom: 1rem;
}
#source {
display: inline;
color: black;
}
This is because you've set a fixed width to your image. By setting the main image to 100% the image will fit and fill up the remaining space so the 3 elements are always distributed equally.
main image size = full width - both your arrows
current
#display {
object-fit: contain;
width: 50rem; /*fixed width*/
height: 30rem; /*fixed width*/
margin-bottom: 1rem;
}
amended
#display {
margin-bottom: 1rem;
width: 100%; /*was added*/
height: auto; /*was added*/
}
jsFiddle
Add css float:"right" in css button.
This question already has answers here:
Make a div span two rows in a grid
(2 answers)
Closed 2 years ago.
I'm using display: flex; to create tiles view.
I'm trying to put the third picture under the second picture.
But, whenever I do it, the third picture went under the first picture and won't come under second picture,
#media screen and (min-width: 1000px) {
.main {
height:1800px;
width: 100%;
margin: 0px 0px 0px 0px;
position: relative;
z-index: 0;
}
.parallax {
/* The image used */
background-image: url("https://i.ibb.co/r272XPt/2019-2020.png");
/* Set a specific height */
min-height: 400px;
opacity: 60%;
filter: blur(2px);
-webkit-filter: blur(2px);
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.tiles{
position:relative;
top:100px;
width:90vw;
margin-left:5vw;
display: flex;
flex-wrap: wrap;
}
.chromebookHelpdesk img{
margin-left:5vw;
width:50vw;
display:block;
}
.subhelp{
height:25vw;
}
.subhelp img{
margin-left:5vw;
width:25vw;
display:block;
}
.studentsTour img{
margin-left:5vw;
width:20vw;
margin-top:5vw;
display:block;
}
#projects img {
text-align: center;
display: block;
width: 25vw;
margin: 20px;
}
.mission_logo {
width: 200px;
display: inline-block;
float: left;
text-align: center;
}
.mission {
text-align: center;
margin-top: 100px;
font-size: 20px;
}
.ingenuity {
color: #3cba54;
font-size: 60px !important;
}
.creativity {
color: #f4c20d;
font-size: 60px !important;
}
.innovation {
color: #db3236;
font-size: 60px !important;
}
}
#media only screen and (max-width: 1000px) {
.main {
height:2500px;
width: 100%;
margin: 0px 0px 0px 0px;
position: relative;
z-index: 0;
}
.parallax {
display: none;
}
.mission_logo {
width: 60vw;
text-align: center;
}
.mission {
text-align: center;
margin-top: 100px;
font-size: 15px;
}
.ingenuity {
color: #3cba54;
font-size: 40px !important;
}
.creativity {
color: #f4c20d;
font-size: 40px !important;
}
.innovation {
color: #db3236;
font-size: 40px !important;
}
}
.tiles h1 {
text-align: center;
font-size: 50px;
color: black;
}
.follow{
position:relative;
top:100px;
text-align:center;
border-radius: 50%;
background-color: #84e3ca;
width: 50vw;
height: 50vw;
margin-left: 25vw;
opacity:70%;
}
.follow h1{
font-size:35px;
padding-top: 20vw;
}
.follow h2{
font-size:30px;
}
<div class="main">
<div class="tiles">
<div class="chromebookHelpdesk"><a href="https://sledteam.github.io/sled/chromebook"><img
src="https://github.com/sledteam/sled/blob/master/Chromebook%20Helpdesk.png?raw=true" alt="Chromebook-Helpdesk"></a></div>
<div class="subhelp"><a href="https://sledteam.github.io/sled/chromebook"><img
src="https://github.com/sledteam/sled/blob/master/Sub%20Help.png?raw=true" alt="Sub Help"></a>
</div>
<div class="studentsTour"><a href="https://sledteam.github.io/sled/chromebook"><img
src="https://github.com/sledteam/sled/blob/master/New%20Students%20Tour.png?raw=true" alt="New Students Tour"></a></div>
</div>
I'm stuck with this for a week.
I would appreciate it if anyone knows a solution for this.
Complete guide to css flexbox
.tiles {
display: flex;
flex-wrap: wrap;
flex-direction: row;
flex: 1;
}
.section {
display: flex;
flex: 1;
flex-direction: column;
}
.item {
display: flex;
flex: 1;
padding: 1rem;
margin: 4px;
background: green;
color: white;
}
<div class="tiles">
<div class="section">
<div class="item">
<p>Chromebook Helpdesk</p>
</div>
</div>
<div class="section">
<div class="item">
<p>Sub Help</p>
</div>
<div class="item">
<p>Student Tour</p>
</div>
</div>
</div>
It is simple if you understand the concept here is the example:
As per your requirement you need 2 columns with single row so you will be creating flex property, now you need 2 columns hence you make it flex:50% like 2. Now coming to your image section where you need 2 images to be underneath so you will provide the height:50%(right images) and you will give height:100%(left image).
You can keep changing the sizes as you desire. You can also add responsive design for the same. Hope it helps.
* {
box-sizing: border-box;
}
.row {
display: flex;
}
.column {
flex: 50%;
padding: 5px;
}
<div class="row">
<div class="column">
<img src="http://i183.photobucket.com/albums/x312/Tiefnuker/office_02_zpsdz0zixcd.jpg" style="width:100%" />
</div>
<div class="column">
<div class="row">
<img src="http://i183.photobucket.com/albums/x312/Tiefnuker/office_02_zpsdz0zixcd.jpg" style="width:50%" />
</div>
<div class="row">
<img src="http://i183.photobucket.com/albums/x312/Tiefnuker/office_02_zpsdz0zixcd.jpg" style="width:50%" />
</div>
</div>
</div>
I have one flexbox with two rows and min-height. The right row has another flex with 2 columns with justify-content space between.
It works perfectly fine in Chrome but it does not fill the min-height in IE. There are many questions about it but none of them worked for me. Please note I have different styles of this where image is on top, bottom or right. I need to expand both content and image to fill the entire card in IE.
Here is the code.
.card-wrap {
display: block;
position: relative;
}
a {
display: block;
}
.card-image-left {
flex-direction: row;
}
.card {
box-sizing: border-box;
display: flex;
border: 1px solid black;
min-height: 200px;
}
.card-content {
padding: 12px;
display: flex;
flex-direction: column;
justify-content: space-between;
flex-grow: 1;
}
.card-text {
font-size: 0.875rem;
color: #1D1D1D;
}
.card-footer {
margin-top: 12px;
}
.card-image-wrap {
overflow: hidden;
position: relative;
}
h3 {
font-size: 1.25rem;
font-weight: 500;
margin: 0 0 4px 0;
}
.card-image {
width: 100%;
background-size: cover;
width:80px;
height: 100%;
background-repeat: no-repeat;
background-position: 50% 50%;
background-image: url("https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg");
}
<div class='card-wrap'>
<a href='#'>
<div class='card card-image-left'>
<div class='image-wrap'>
<div class='card-image'>
</div>
</div>
<div class='card-content'>
<div class='card-header'>
<h3>test title</h3>
<div class='card-text'>test subtitlte</div>
</div>
<div class='card-footer'>
<div>
<div class='card-footer-monetary'>1000</div>
</div>
</div>
</div>
</div>
</a>
</div>
Image from IE
Its a bug in IE 10-11. In IE 10-11, min-height declarations on flex containers work to size the containers themselves, but their flex item children do not seem to know the size of their parents. They act as if no height has been set at all.
More info: https://github.com/philipwalton/flexbugs#flexbug-3
Workaround
Simply wrap the flex container (here it div with classname card) with another flex-container having flex direction column
.ie-fix-wrapper{
display: flex;
flex-direction:column;
}
.card-wrap {
display: block;
position: relative;
}
a {
display: block;
}
.card-image-left {
flex-direction: row;
}
.card {
box-sizing: border-box;
display: flex;
border: 1px solid black;
min-height: 200px;
}
.card-content {
padding: 12px;
display: flex;
flex-direction: column;
justify-content: space-between;
flex-grow: 1;
}
.card-text {
font-size: 0.875rem;
color: #1D1D1D;
}
.card-footer {
margin-top: 12px;
}
.card-image-wrap {
overflow: hidden;
position: relative;
}
h3 {
font-size: 1.25rem;
font-weight: 500;
margin: 0 0 4px 0;
}
.card-image {
width: 100%;
background-size: cover;
width:80px;
height: 100%;
background-repeat: no-repeat;
background-position: 50% 50%;
background-image: url("https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg");
}
<div class='card-wrap'>
<a href='#'>
<div class="ie-fix-wrapper">
<div class='card card-image-left'>
<div class='image-wrap'>
<div class='card-image'>
</div>
</div>
<div class='card-content'>
<div class='card-header'>
<h3>test title</h3>
<div class='card-text'>test subtitlte</div>
</div>
<div class='card-footer'>
<div>
<div class='card-footer-monetary'>1000</div>
</div>
</div>
</div>
</div>
</div>
</a>
</div>
The solution provided by #Soothran works well. There is also alternative solution that is quicker to implement - inherit min-height in the children. In this case of the code above:
.image-wrap {
min-height: inherit;
}
.card-content {
min-height: inherit;
}
.card-wrap {
display: block;
position: relative;
}
a {
display: block;
}
.card-image-left {
flex-direction: row;
}
.card {
box-sizing: border-box;
display: flex;
border: 1px solid black;
min-height: 200px;
}
.card-content {
min-height: inherit;
padding: 12px;
display: flex;
flex-direction: column;
justify-content: space-between;
flex-grow: 1;
}
.card-text {
font-size: 0.875rem;
color: #1D1D1D;
}
.card-footer {
margin-top: 12px;
}
.card-image-wrap {
overflow: hidden;
position: relative;
}
h3 {
font-size: 1.25rem;
font-weight: 500;
margin: 0 0 4px 0;
}
.image-wrap {
min-height: inherit;
}
.card-image {
width: 100%;
width:80px;
height: 100%;
background: black;
}
<div class='card-wrap'>
<a href='#'>
<div class='card card-image-left'>
<div class='image-wrap'>
<div class='card-image'>
</div>
</div>
<div class='card-content'>
<div class='card-header'>
<h3>test title</h3>
<div class='card-text'>test subtitlte</div>
</div>
<div class='card-footer'>
<div>
<div class='card-footer-monetary'>1000</div>
</div>
</div>
</div>
</div>
</a>
</div>
You need to wrap any flex-direction:column inside a flex-direction:row
(or just display:flex for simple)
This question already has answers here:
Flexbox on IE11: image stretched for no reason?
(6 answers)
Closed 5 years ago.
I have a flexbox grid layout that has one tall image in one column and two shorter images stacked on top of each other in another column.
This is what it looks like it Chrome:
In Internet Explorer, the height of the two smaller nested images/divs get stretched to the first column's height.
How do I make the column with two nested images keep their own height?
h3 {
margin-bottom: 20px;
}
.grid {
box-sizing: border-box;
display: -ms-flexbox;
display: flex;
-ms-flex-flow: row nowrap;
flex-flow: row nowrap;
margin-left: -10px;
margin-right: -10px;
}
.col-4 {
padding-left: 10px;
padding-right: 10px;
box-sizing: border-box;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
flex-basis: 33.33333%;
max-width: 33.33333%;
}
.executive-container {
max-width: 1440px;
margin-top: 0;
margin-bottom: 0;
margin-left: auto !important;
margin-right: auto !important;
padding: 0 5.21%;
padding-top: 80px;
padding-bottom: 0;
}
.executive-container .box {
margin-bottom: 20px;
-ms-flex-order: 1;
order: 1;
}
.executive-container .box .box-inner {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
-ms-flex-pack: justify;
justify-content: space-between;
height: 100%;
}
.resimg {
width: 100%;
height: auto;
vertical-align: bottom;
}
.executive-container .box .board-member {
position: relative;
}
.executive-container .box .board-member .board-member-details {
width: 66%;
position: absolute;
bottom: 0;
left: 0;
color: red;
padding: 20px;
font-size: 1.8rem;
letter-spacing: 0;
font-weight: normal;
font-style: normal;
line-height: 2.9rem;
font-weight: 700;
line-height: 2.1rem;
letter-spacing: -0.02em;
}
<div class="grid executive-container">
<div class="box col-4 heading">
<h3>Executive<br>Leadership<br>Team</h3></div>
<div class="box col-12_sm-6_md-4">
<div class="board-member">
<div class="board-member-details">
<div class="board-name">Caption</div>
</div>
<img src="http://via.placeholder.com/821x1125" alt="" class="resimg portrait-desktop">
</div>
</div>
<div class="box col-4">
<div class="box-inner">
<div class="board-member">
<div class="board-member-details">
<div class="board-name">Caption</div>
</div><img src="http://via.placeholder.com/819x536" alt="" class="resimg"></div>
<div class="board-member">
<div class="board-member-details">
<div class="board-name">Caption</div>
</div><img src="http://via.placeholder.com/819x536" alt="" class="resimg"></div>
</div>
</div>
</div>
This helped! Flexbox on IE11: image stretched for no reason?
I set flex-shrink: 0 on the flex-child and it solved the problem in IE.