Struggling with creating responsive proportional rectangles for my gallery. It was working fine until I tried to center the text vertically, but couldn't figure out how to do it while maintaining proportional resizing. Any help or advice would be greatly appreciated. Thanks.
#container{
margin-left:auto;
margin-right:auto;
}
#MyList li{
float: left;
background-image: url(../images/bardiches.png);
background-size: cover;
background-position: center;
}
#MyList a{
text-align: center;
line-height: 100%;
display: block;
background-color: rgba(255,255,255,.0);
transition: background-color 500ms ease-out;
}
#MyList a:hover{
background-color: rgba(255,255,255,.95);
}
Styles for Desktop/Tablet Devices
@media only screen and (min-width: 768px){
#container{
width:80%;
}
#MyList li{
width:46%;
margin-bottom:50px;
margin-left: 2%;
margin-right: 2%;
}
#MyList li:nth-child(4n){
margin-right:0px;
}
#MyList a{
height:100%;
padding-bottom: 55%;
}
}
HTML Code
<div id="container">
<ul id="MyList">
<li>
<a href="#">
Bardiches
</a>
</li>
<li>
<a href="#">
Bardiches
</a>
</li>
<li>
<a href="#">
Bardiches
</a>
</li>
<li>
<a href="#">
Bardiches
</a>
</li>
<li>
<a href="#">
Bardiches
</a>
</li>
<li>
<a href="#">
Bardiches
</a>
</li>
</ul>
</div>
Check out my test site here:-