i like to have my webpage to be centered vertically and horizontally. i have tried many options but nothing successful. help me. Basically its a thumbnail image gallery page and i am using photoswipe. Everything is fine except i cannot make the page centered.
My HTML code
<div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp1-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp1.jpg" itemprop="thumbnail"></a>
<figcaption>1</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp2-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp2.jpg" itemprop="thumbnail"></a>
<figcaption>2</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp3-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp3.jpg" itemprop="thumbnail"></a>
<figcaption>3</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp4-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp4.jpg" itemprop="thumbnail"></a>
<figcaption>4</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp5-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp5.jpg" itemprop="thumbnail"></a>
<figcaption>5</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp6-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp6.jpg" itemprop="thumbnail"></a>
<figcaption>6</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp7-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp7.jpg" itemprop="thumbnail"></a>
<figcaption>7</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp8-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp8.jpg" itemprop="thumbnail"></a>
<figcaption>8</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp9-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp9.jpg" itemprop="thumbnail"></a>
<figcaption>9</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp10-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp10.jpg" itemprop="thumbnail"></a>
<figcaption>10</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp11-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp11.jpg" itemprop="thumbnail"></a>
<figcaption>11</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp12-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp12.jpg" itemprop="thumbnail"></a>
<figcaption>12</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp13-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp13.jpg" itemprop="thumbnail"></a>
<figcaption>13</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp14-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp14.jpg" itemprop="thumbnail"></a>
<figcaption>14</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp15-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp15.jpg" itemprop="thumbnail"></a>
<figcaption>15</figcaption>
</figure>
</div>
My CSS code:
.my-gallery {
margin-left: auto;
margin-right: auto;
width:100%;
}
.my-gallery img {
width: 100%;
height: auto;
}
.my-gallery figure {
display: block;
float: left;
width: auto;
margin: 0 auto;
text-align: center;
font: 15px Arial, sans-serif;
border: thin silver solid;
margin: 5px 5px;
padding: 0.1em;
}
.my-gallery figcaption {
padding-top: 1px;
padding-bottom: 1px;
}
How to make it centered?
My Full code
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Multiple PhotoSwipe galleries on page</title>
<link rel="stylesheet" href="css/photoswipe.min.css">
<link rel="stylesheet" href="css/default-skin/default-skin.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp1-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp1.jpg" itemprop="thumbnail"></a>
<figcaption>1</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp2-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp2.jpg" itemprop="thumbnail"></a>
<figcaption>2</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp3-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp3.jpg" itemprop="thumbnail"></a>
<figcaption>3</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp4-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp4.jpg" itemprop="thumbnail"></a>
<figcaption>4</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp5-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp5.jpg" itemprop="thumbnail"></a>
<figcaption>5</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp6-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp6.jpg" itemprop="thumbnail"></a>
<figcaption>6</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp7-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp7.jpg" itemprop="thumbnail"></a>
<figcaption>7</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp8-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp8.jpg" itemprop="thumbnail"></a>
<figcaption>8</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp9-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp9.jpg" itemprop="thumbnail"></a>
<figcaption>9</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp10-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp10.jpg" itemprop="thumbnail"></a>
<figcaption>10</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp11-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp11.jpg" itemprop="thumbnail"></a>
<figcaption>11</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp12-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp12.jpg" itemprop="thumbnail"></a>
<figcaption>12</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp13-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp13.jpg" itemprop="thumbnail"></a>
<figcaption>13</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp14-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp14.jpg" itemprop="thumbnail"></a>
<figcaption>14</figcaption>
</figure>
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="images/rp15-1.jpg" itemprop="contentUrl" data-size="1400x2100">
<img src="images/rp15.jpg" itemprop="thumbnail"></a>
<figcaption>15</figcaption>
</figure>
</div>
<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<!-- Background of PhotoSwipe.
It's a separate element, as animating opacity is faster than rgba(). -->
<div class="pswp__bg"></div>
<!-- Slides wrapper with overflow:hidden. -->
<div class="pswp__scroll-wrap">
<!-- Container that holds slides. PhotoSwipe keeps only 3 slides in DOM to save memory. -->
<!-- don't modify these 3 pswp__item elements, data is added later on. -->
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<!-- Controls are self-explanatory. Order can be changed. -->
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
<button class="pswp__button pswp__button--share" title="Share"></button>
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
<!-- element will get class pswp__preloader--active when preloader is running -->
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
</button>
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>
<script src="js/photoswipe.min.js"></script>
<script src="js/photoswipe-ui-default.min.js"></script>
<script src="js/index.js"></script>
</body>
</html>
I want the class "my-gallery" to be centered. i can able to make the body center using section tag.