0

I would like the images within the scrolling portion of my wrapper to float in the middle of the screen (wide) and enlarge/shrink if the screen changes size. Currently it sits beneath the header but is well above the footer. How can I get it to center vertically?

CSS:

/* main content
------------------------------------------------------------------- */  

#wrapper {
   float:left;
   margin:110px 0 0 0;
   padding:0 0 0 250px;
   background:#fff;
   position:relative;
   z-index:2;
   border-bottom:solid 20px #fff;
}   
.post {
    padding:0 5px 0 0;
    background:#fff;
    height:100%;
    }
#wrapper img {
 color:#fff;
 width:auto;
 }

The HTML:

<!-- section that contains all pics -->
<section id="wrapper">
    <article class="post">
    <p><img src="img/scroll/001_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
    </article>

    <article class="post">
    <p><img src="img/scroll/002_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
    </article>

    <article class="post">
    <p><img src="img/scroll/003_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
    </article>

    <article class="post">
    <p><img src="img/scroll/004_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
    </article>

    <article class="post">
    <p><img src="img/scroll/005_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
    </article>

</section>
<!-- close section -->

Thanks in advance guys!

rivenagares
  • 117
  • 1
  • 7
  • possible duplicate of [What's The Best Way of Centering a Div Vertically with CSS](http://stackoverflow.com/questions/396145/whats-the-best-way-of-centering-a-div-vertically-with-css) – bjb568 Jan 14 '14 at 16:39
  • possible solution found on this thread, but no answer selected http://stackoverflow.com/questions/396145/whats-the-best-way-of-centering-a-div-vertically-with-css – Marriott81 Jan 14 '14 at 16:24

2 Answers2

1

If you want to use CSS tables, I would suggest:

.post {
    display: table;
}
.post p {
    display: table-cell;
    vertical-align: middle;
    height: inherit; /* may not be needed */
}

The display: table{-cell} properties are pretty well supported in the newer browsers, so this should do the trick.

Marc Audet
  • 46,011
  • 11
  • 63
  • 83
0

Some solutions come to mind of how to vertically center a div.

#wrapper {
 float:left; /**REMOVE THIS**/
 margin:110px 0 0 0; /** REMOVE THIS **/
 padding:0 0 0 250px; /** REMOVE THIS **/
 width: 100%; /** ADD THIS **/
 height: 100% /** ADD THIS **/
 background:#fff;
 position:relative; /** REMOVE THIS **/
 z-index:2;  /** REMOVE THIS **/
 border-bottom:solid 20px #fff; /** REMOVE THIS **/
}
#wrapper {
 width: 100%; 
 height: 100%;
 min-height: 100%;
 background:#fff;
 position: absolute;
}   
.post {
  padding:0 5px 0 0;
  background:#fff;
  height:100%;
  }
 #wrapper img {
  color:#fff;
  width:auto;
 }
#content {
  position: relative;
  width: 60%;
  height: 60%;
  top: 50%;
  left: 50%;
}

HTML

<section id="wrapper">
  <div id="content"> <!-- ADD THIS This will be used to position vertically-->
  <article class="post">
<p><img src="img/scroll/001_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>

<article class="post">
<p><img src="img/scroll/002_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>

<article class="post">
<p><img src="img/scroll/003_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>

<article class="post">
<p><img src="img/scroll/004_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>

<article class="post">
<p><img src="img/scroll/005_scroll.jpg" alt="test image 1" title="test image" width="994" height="620" class="alignnone size-full wp-image-240" /></p>
</article>

There is more that needs to be added to make this better, but this will get you started in the right direction. http://jsfiddle.net/cornelas/qCa3J/

Cam
  • 1,884
  • 11
  • 24