0

I have HTML structure like this :

<div class="card-container">
                <div class="intro-card">
                    <img src="/Users/thangna/Desktop/snkr/thang-files/webdev.jpeg" alt="">
                    <h3>CAREER</h3>
                    <p>Realizing that becoming a great web developer is not easy, I'm trying my best to achieve my targets everyday to level up myself. My journey as well as my achievement in my web developing career will be updated here once I have free timm !</p>
                </div>
                <div class="intro-card">
                    <img src="/Users/thangna/Desktop/snkr/thang-files/bball.jpeg" alt="">
                    <h3>BASKETBALL</h3>
                    <p>Realizing that becoming a great web developer is not easy, I'm trying my best to achieve my targets everyday to level up myself. My journey as well as my achievement in my web developing career will be updated here once I have free timm !</p>
                </div>
                <div class="intro-card">
                    <img src="/Users/thangna/Desktop/snkr/thang-files/webdev.jpeg" alt="">
                    <h3>CAREER</h3>
                    <p>Realizing that becoming a great web developer is not easy, I'm trying my best to achieve my targets everyday to level up myself. My journey as well as my achievement in my web developing career will be updated here once I have free timm !</p>
                </div>
            </div> 

and its CSS below:

.card-container {
display: flex;
flex: auto;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-left: auto;}

.intro-card {
display: flex;
flex: auto;
flex-direction: column;
justify-content: center;
width: 25%;
height: 700px;
border-radius: 20px;
background-color: #fff  ;
padding: 10px;
margin: 5% 20px;};

.intro-card > img{
height: 200px;}

.intro-card > h3 {
margin: 10px;
text-align: center;}

As you can see , I really want to set the height of the image in the flex card to be 200 px but when I did it in CSS code, nothing changed ! enter image description here

You can see from the image, the image in the second card is still longer than the rest.

But I can change it to the same height when i added inline style directly to the img tag in my html code ! Can anyone explain for me why this happen and the solution to it ? Thank you a lot !

1 Answers1

0

To give a higher priority to height put CSS at end of the CSS file.

In chrome, to apply img CSS there should be a pre-defined css for flex.

i.e.: img{ min-height: 0 }

Here is solution why it's not working in chrome. Image height inside flexbox not working in Chrome

Punit Patel
  • 351
  • 2
  • 11