我正在尝试向我的投资组合网站添加一些平滑滚动,这样当您单击项目按钮时,它将加载新页面并向下平滑滚动到项目 - http://www.mattdbryce.co.uk/。我找到了这段代码 - http://css-tricks.com/snippets/jquery/smooth-scrolling/ - 但是它只允许平滑滚动同一页面上的链接。当我使用此代码时,无论您在导航中单击哪个链接,它都会在现有页面上平滑向下滚动。
我考虑过有很多锚标签的长页面,但这不会永远加载吗?
有什么想法吗?
非常感谢,
马特
我的 HTML:
<!DOCTYPE HTML>
<head>
<!--web fonts-->
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400italic,700italic' rel='stylesheet' type='text/css'>
<!--end web fonts-->
<meta charset="UTF-8">
<title>Matt Bryce | East London Graphic Design, Web Design, Logo Design and Brand Identity</title>
<!--css files-->
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/text.css">
<link rel="stylesheet" href="css/960_24_col.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<!--End css files-->
<!--JS-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/smooth-scroll.js"></script>
<!--END JS-->
<!--favicon-->
<link rel="shortcut icon" href="favicon.png">
<!--End favicon-->
</head>
<body>
<div class="shadow">
<div class="container_24">
<header>
<h1 class="clearfix"><a href="index.html">Matt Bryce</a></h1>
<div id="title"><h2>Matthew Bryce Portfolio</h2></div>
<nav>
<ul>
<li><a href="mailto:info@mattdbryce.co.uk"><img src="img/contact.png" alt="Contact"/></a></li>
</ul>
</nav>
</header>
<div class="portfolio-nav">
<div class="grid_4">
<h3><a href="good-taste.html#project-top"><img src="img/good-taste-button-1.png" alt="Good Taste Delicatessen - Branding + Website"></a>Good Taste Delicatessen</h1>
<p>Branding + Website</p>
</div>
<div class="grid_4">
<h3><a href="jims-cafe.html#project-top"><img src="img/jims-cafe-button-1.png" alt="Jim's Cafe - Logo Design"></a>Jim's Cafe</h1>
<p>Logo Design</p>
</div>
<div class="grid_4">
<h3><a href="coffee-revolution.html#project-top"><img src="img/the-coffee-revolution-button-1.png" alt="The Coffee Revolution - Events Poster"></a>The Coffee Revolution</h1>
<p>Events Poster</p>
</div>
<div class="grid_4">
<h3><a href="wilton-way.html#project-top"><img src="img/wilton-way-cafe-button-1.png" alt="Wilton Way Cafe - Logo Design"></a>The Wilton Way Cafe</h1>
<p>Logo Design</p>
</div>
<div class="grid_4">
<h3><a href="halligan-poster.html#project-top"><img src="img/halligan-poster-button-1.png" alt="Halligan - Gig Poster"></a>Halligan</h1>
<p>Gig Poster</p>
</div>
<div class="grid_4">
<h3><a href="mj-wedding.html#project-top"><img src="img/martyn-and-jo-button-1.png" alt="Martyn + Jo - Wedding Invitiations"></a>Martyn + Jo</h1>
<p>Wedding Invitation</p>
</div>
<div class="grid_4">
<h3><a href="dog-and-wardrobe.html#project-top"><img src="img/the-dog-and-wardrobe-button-1.png" alt="The Dog + Wardrobe - Campaign Material"></a>The Dog + Wardrobe</h1>
<p>Campaign Material</p>
</div>
<div class="grid_4">
<h3><a href="early-years.html#project-top"><img src="img/the-early-years-button-1.png" alt=""></a>The Early Years</h1>
<p>Gig Poster</p>
</div>
<div class="grid_4">
<h3><a href="halligan-album.html#project-top"><img src="img/halligan-album-button-1.png" alt="Halligan - Album Artwork"></a>Halligan</h1>
<p>Album Artwork</p>
</div>
<div class="grid_4">
<h3><a href="part-chimp.html#project-top"><img src="img/part-chimp-button-1.png" alt="Part Chimp - Gig Poster"></a>Part Chimp</h1>
<p>Gig Poster</p>
</div>
</div>
<footer><p>Copyright Matthew Bryce Design</p></footer>
</div> <!--end container-->
</div>
<!--JQuery-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!--Include plugin-->
<!--hook it up-->
</body>