以下是我要执行的内容:
所以我想这张照片应该修好。难以创建的部分是,一旦窗口到达半照片的点,下面的半个故事,下面的故事应该开始覆盖照片(直到照片不再可见)并且页面开始向上滚动。
这是我的fiddle和代码:
<body>
<header> <span class="white">Home</span></header>
<!--A FIXED HEADER ALWAYS IN SIGHT-->
<div id="content">
<section class="intro">
<!--CONTAINER FOR PHOTO AND HEADLINE-->
<h1 class="atop">Headline</h1>
<img class="scrollimg" src="http://ww2.hdnux.com/photos/23/74/63/5229797/3/1200x706.jpg"/>
</section>
<!--SECTION SHOULD BE FIXED BUT ONCE SCROLLED 75% OF PHOTO, STORY CONTAINER BELOW SHOULD BEGIN TO COVER PHOTO-->
<section class="story">
<!--CONTAINER FOR STORY WITH WHITE BACKGROUND BEGINS TO COVER PHOTO UPON SCROLLING DOWN-->
<div id="row">
<!--DUMMY COPY-->
<h1>HTML Ipsum Presents</h1>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
<h1>HTML Ipsum Presents</h1>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
</div>
</section>
</div>
<div id="footer">FOOTER</div>
我认为是来自another fiddle的一些有用的代码。
小提琴似乎执行了类似的技巧,因为页脚在滚动时到达设定位置时会将内容推高。
答案 0 :(得分:0)
怎么样 http://jsfiddle.net/anaran/gYxK4/
根本没有JS。
另见https://developer.mozilla.org/en-US/docs/Web/CSS/position
position: fixed;
不为这样的元素留下空间。
因此需要指定相对位置并指定相对位置。
我添加了您可能喜欢或不喜欢的白色背景。
.story {
position: relative;
background: white;
padding: 4%;
top: 850px;
left: 30px;
}