I'm attempting to center an image wrapped by an anchor tag inside a div. I've attempted to use display flexbox and justify-content:center
the image which works to an extent, but The height of the image remains the same whilst the width changes accordingly, so squashes the image as I scale down from desktop to mobile... thus losing its quality.
How can I center this image.
Note: I'm using bourbon neat
Here's what I have
HTML
<div class="project">
<a class="project__thumb" href="{{ project.url }}" target="_blank">
<img src="{{ site.baseurl }}img/{{ project.thumbnail }}">
</a>
</div>
SCSS
.project{
width: 80%;
margin: 0 auto; /*center whole block for mobile*/
height: auto;
margin-bottom: 60px;
border-radius: 2px;
position: relative;
a{
display: flex;
justify-content: center;
}
img{
max-width: 100%; /*make image responsive*/
height: auto; /*make image responsive*/
border-radius: 2px;
transition: opacity 0.25s ease-in-out;
}
}
@include media ($tablet){
.main__projects{
@include span-columns(12);
}
.project{
@include span-columns(6 of 12);
@include omega(2n);
margin-bottom: 50px;
}
}
@include media ($desktop){
.main__projects{
@include span-columns(12);
}
.project{
@include span-columns(4 of 12);
@include omega(3n);
margin-bottom: 100px;
}
}