I have a page containing rows of images in a flexbox container. I'm attempting to link these images to their source images, and when surrounding the images with an <a>
tag, the image no longer conforms to the boundaries of its parent container. I realize this is likely because the <a>
tag becomes the <img>
tag's parent, but I'm inheriting attributes from the parent container, so the <a>
tag should be styled the same.
How can I get the image to respect the 350x225 boundary with this setup?
With Link:
.frame {
display: flex;
flex-direction: column;
width: 100%;
height: auto;
}
.frame-row {
display: flex;
flex-direction: row;
width: 100%;
justify-content: space-around;
margin-top: 5%;
}
.frame-item {
position: relative;
width: 350px;
height: 225px;
max-width: 31%;
}
.frame-item a {
width: inherit;
height: inherit;
max-width: inherit;
}
.frame-item>img {
width: 100%;
height: 100%;
}
<div class="frame-row">
<div class="frame-item">
<a href="http://placehold.it/1000">
<img src="http://placehold.it/1000">
<div class="item-overlay">
<p>Grand Royale Ct.<br> Alamo, CA</p>
</div>
</a>
</div>
</div>
Without Link:
.frame {
display: flex;
flex-direction: column;
width: 100%;
height: auto;
}
.frame-row {
display: flex;
flex-direction: row;
width: 100%;
justify-content: space-around;
margin-top: 5%;
}
.frame-item {
position: relative;
width: 350px;
height: 225px;
max-width: 31%;
}
.frame-item a {
width: inherit;
height: inherit;
max-width: inherit;
}
.frame-item>img {
width: 100%;
height: 100%;
}
<div class="frame-row">
<div class="frame-item">
<img src="http://placehold.it/1000">
<div class="item-overlay">
<p>Street<br> City, State</p>
</div>
</div>
</div>