您将不得不修改您的 HTML。前段时间我通过了一个解决方案,但我不记得它在哪里。无论如何,这是我修改代码的方式:
HTML:
<a id="nav1"></a>
<a id="nav2"></a>
<a id="nav3"></a>
<header class="nav">
<nav>
<ul>
<li><a href="#nav1">Home</a> </li>
<li><a href="#nav2">About</a></li>
<li><a href="#nav3">Contact</a></li>
</ul>
</nav>
</header>
<section id="main">
<article class="article" id="nav1">
<p>Big Tech Ideas Page3</p>
</article>
<article class="article" id="nav2">
<p>Big Tech Ideas Page3</p>
</article>
<article class="article" id="contacto">
<p>Big Tech Ideas Page3</p>
</article>
</section>
CSS:
a[id= "nav1"]:target ~ #main article.article {
-webkit-transform: translateY( 0px);
transform: translateY( 0px );
}
a[id= "nav2"]:target ~ #main article.article {
-webkit-transform: translateY( -500px );
transform: translateY( -500px );
}
a[id= "nav3"]:target ~ #main article.article {
-webkit-transform: translateY( -1000px );
transform: translateY( -1000px );
}
header {
position: fixed;
z-index: 10;
}
.article {
width: 100%;
height: 600px;
z-index:0;
-webkit-transform: translateZ( 0 );
transform: translateZ( 0 );
-webkit-transition: -webkit-transform 2s ease-in-out;
transition: transform 2s ease-in-out;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.article p {
font-family: sans-serif;
font-size: 86px;
font-size: 5rem;
position:relative;
line-height: 300px;
text-align: center;
margin: 0;
}
让我知道它是否有效。
工作演示小提琴:http: //jsfiddle.net/Fraximus/CFSEK/1/