I'm trying to center a set of divs (1 class) at the center of the screen. My problem is that each div has different dimensions. I've followed some guidelines I found to center the divs with jQuery:
$(document).ready(function () {
$(".content").position({
"my": "center center",
"at": "center center",
"of": "center center"
});
});
but this doesn't seem to work for me: https://i.stack.imgur.com/xSJJT.png What am I doing wrong?
HTML:
<div class="galleryarea">
<div class="galleryframe">
<div class="galleryentity" style="background-image:url('link_here');">
<a href="javascript:void(0)" class="gallerylink" onclick = "document.getElementById('pic1').style.display='block';document.getElementById('fade').style.display='block'"></a>
<div id="pic1" class="content"><img class="galleryfullsize" src="link_here"></div>
</div>
</div>
CSS:
.galleryentity{
display: table;
margin-bottom: 35px;
float: left;
width: 259px;
height: 250px;
background-color: #2B3039;
margin-right: 30px;
position: relative;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
-webkit-box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
}
.white_content {
display: none;
position: absolute;
margin: 0 auto;
border: 8px solid orange;
background-color: #eee;
z-index:1002;
overflow: auto;
}
.newsframe{
display: inline-block;
margin: 0 auto;
max-width: 1200px;
margin-top: 35px;
}
.newsentity{
display: table;
float: left;
width: 259px;
height: 250px;
background-color: #2B3039;
margin-right: 30px;
position: relative;
-webkit-box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
box-shadow: 0px 3px 5px 2px rgba(50, 50, 50, 0.75);
}
.newsarea{
width: 100%;
min-height: 320px;
background-color: #3F444D;
text-align: center;
}