0

I'm working on what should be a simple website, and I'm running into an issue I can't put my finger on.

I've got each <section> set to the full height, then some nested sections to get content centered on the page. I'm seeing strange performance when I scroll off the first page into the second. To reproduce, resize the browser. My expected performance is to have all elements resize and stay in the middle of the browser window.

The problem comes when you scroll down to the second screen. Resizing the browser window causes the content-center class to bleed into the next section. I think it's because the image isn't resizing, and I can't seem to get this related answer to take care of the image.

Here's a Fiddle showing the behavior. Code snippets are below.

HTML

<section id="wrapper">
            <section id="pages">
                <section class="page active" id="page1">
                    <section class="content-container">
                        <section class="content-center">
                            <h1>Section 1</h1>
                            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>    
                        </section>
                    </section>
                </section>
                <section class="page" id="page2">
                    <section class="content-container">
                        <section class="content-center">
                            <h1>Section 2</h1>
                            <img src="https://farm8.staticflickr.com/7392/12829130433_ee4071030b_b.jpg" />
                            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
                        </section>
                    </section>
                </section>
                <section class="page" id="page3">
                    <section class="content">
                        <h1>Section 3</h1>
                        <img src="https://farm8.staticflickr.com/7392/12829130433_ee4071030b_b.jpg" />
                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
                    </section>
                </section>
        <section id="nav">
            <a id="next" href="#"></a>
            <a id="prev" href="#"></a>
        </section>

CSS

html, body {
    margin:0;
    padding:0;
    height:100%;
}
#wrapper {
    height:100%;
}

#pages {
    width: 100%;
    height:100%;
    position:relative;
}

/** nav **/
#nav {
    display:inline;
    width:auto;
    height:50px;
    position:fixed;
    bottom:35px;
    left:35px;
    background:rgba(220,220,220,0.7);
    border-radius:5px;
}

#nav #next {
    height:48px;
    width:48px;
    cursor:pointer;
    display:inline-block;
    background:url(http://icons.iconarchive.com/icons/visualpharm/ios7v2/48/Arrows-Down-icon.png);
}

#nav #prev {
    height:48px;
    width:48px;
    background:url(http://icons.iconarchive.com/icons/visualpharm/ios7v2/48/Arrows-Up-icon.png);
    cursor:pointer;
    display:inline-block;
}

/** page structure **/
.page {
    height:100%;
}

.content-container {
    width:580px;
    height:100%;
    margin:0 auto;
    padding:15px;
}

.content-center {
    width:100%;
    height:auto;
    margin:0 auto;
    padding:15px;
    background:rgba(225,225,225,0.7);
    border-radius:5px;

    position:relative;
    top:50px;
    left:0;
    bottom:0;
    right:0;
}

.content-center img {
    height:auto;
    max-width:100%;  
}

#page1 {
    display:block;
    background:url(https://farm3.staticflickr.com/2865/13367252423_9800f13cd3_b.jpg) fixed center center no-repeat;
    background-size: cover;
}

#page1 p {
    font-size:3.5vmin;
    margin:0;
}

#page2 {
    display:block;
    background:url(https://farm9.staticflickr.com/8394/10187216006_ed71530f7e_b.jpg) fixed center center no-repeat;
    background-size: cover;
}

#page2 h1{
    text-align: center;
}
Community
  • 1
  • 1
Brian
  • 4,274
  • 2
  • 27
  • 55
  • from what you have here the only solution i can think is add `position:absolute;` to `html, body {}`. You'll have to put it in a div as to not alter the html or do a bit of resizing though...[fiddle](http://jsfiddle.net/BJp6X/1/) – 13ruce1337 Apr 19 '14 at 03:06
  • Yeah, that's what I was thinking, too...I feel like I'm missing something simple, though. It isn't going to be published widely, so I might just forget about the resizing for now if it turns into a can of worms. – Brian Apr 19 '14 at 03:11
  • well if thats the case just throw it in `body{}` as to not disturb all the html. – 13ruce1337 Apr 19 '14 at 03:12

0 Answers0