$(function() {
\t var navLinks = $('nav ul li a'),
\t \t \t navH = $('nav').height(),
\t \t \t section = $('section'),
\t \t \t documentEl = $(document);
\t documentEl.on('scroll', function() {
\t \t \t var currentScrollPos = documentEl.scrollTop();
\t \t \t section.each(function() {
\t \t \t \t \t var self = $(this);
\t \t \t \t \t if (self.offset().top < (currentScrollPos + navH) && (currentScrollPos + navH) < (self.offset().top + self.outerHeight())) {
\t \t \t \t \t \t \t var targetClass = '.' + self.attr('class') + '-marker';
\t \t \t \t \t \t \t navLinks.removeClass('active');
\t \t \t \t \t \t \t $(targetClass).addClass('active');
\t \t \t \t \t }
\t \t \t });
\t });
})();
@charset "utf-8";
* {
/*reset*/
background: none repeat scroll 0 0 transparent;
border: medium none;
border-spacing: 0;
font-size: 16px;
font-weight: normal;
line-height: 1.42rem;
list-style: none outside none;
margin: 0;
padding: 0;
text-align: left;
text-decoration: none;
text-indent: 0;
box-sizing: border-box;
}
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
\t margin: 0;
\t padding: 0;
\t border: 0;
\t font-size: 100%;
\t font: inherit;
\t vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
\t display: block;
}
body {
\t line-height: 1;
}
ol, ul {
\t list-style: none;
}
blockquote, q {
\t quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
\t content: '';
\t content: none;
}
table {
\t border-collapse: collapse;
\t border-spacing: 0;
}
button{
-webkit-appearance: none !important;
}
a{
-webkit-appearance: none;
}
/*End Reset*/
/*Fonts*/
@font-face {
font-family: 'bebas_neuebold';
src: url('../fonts/bebasneue_bold-webfont.woff2') format('woff2'),
url('../fonts/bebasneue_bold-webfont.woff') format('woff');
}
@font-face {
font-family: 'bebas_neuebook';
src: url('../fonts/bebasneue_book-webfont.woff2') format('woff2'),
url('../fonts/bebasneue_book-webfont.woff') format('woff');
}
@font-face {
font-family: 'bebas_neuelight';
src: url('../fonts/bebasneue_light-webfont.woff2') format('woff2'),
url('../fonts/bebasneue_light-webfont.woff') format('woff');
}
@font-face {
font-family: 'bebas_neue_regularregular';
src: url('../fonts/bebasneue_regular-webfont.woff2') format('woff2'),
url('../fonts/bebasneue_regular-webfont.woff') format('woff');
}
@font-face {
font-family: 'bebas_neuethin';
src: url('../fonts/bebasneue_thin-webfont.woff2') format('woff2'),
url('../fonts/bebasneue_thin-webfont.woff') format('woff');
}
@font-face {
font-family: 'bebas_neueregular';
src: url('../fonts/bebasneue-webfont.woff2') format('woff2'),
url('../fonts/bebasneue-webfont.woff') format('woff');
}
.bebas-bold{
\t font-family: bebas_neuebold !important;
letter-spacing: 0.05em;
}
.bebas-book{
\t font-family: bebas_neuebook !important;
}
.bebas-light{
\t font-family: bebas_neuelight !important;
letter-spacing: 0.05em;
}
.bebas-thin{
font-family: bebas_neuethin !important;
letter-spacing: 0.05em;
}
.bebas-reg{
\t font-family: bebas_neue_regularregular !important;
letter-spacing: 0.05em;
}
/*End fonts*/
body {
font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
background-color: #505050;
padding: 0px;
margin: 0px;
}
/*Header*/
#navwrapper{
width: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
right: 0;
}
li img {
\t height:95px;
\t width:95px;
}
ul{
display: table;
margin: 0 auto;
}
ul.topnav {
padding: 0;
overflow: hidden;
}
.toggleNavButton {
transition-duration: 0.5s;
width: 40px;
height: 2px;
background-color: black;
position: absolute;
/*left: 50%;*/
top: 25px;
margin-left: 20px;
border-radius: 2px;
}
.toggleNavButton:before,
.toggleNavButton:after {
border-radius: 2px;
transition-duration: 0.5s;
content: "";
position: absolute;
top: 10px;
left: 0;
background-color: black;
width: 40px;
height: 2px;
}
.toggleNavButton:after {
top: 20px;
}
.toggleNavButton.active {
width: 0;
}
.toggleNavButton.active:after {
top: 10px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.toggleNavButton.active:before {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
/* Float the list items side by side */
nav ul.topnav li {
float: left;
}
.padnav{
padding: 0px 35px 0px 35px;
margin-top:35px;
}
/* Style the links inside the list items */
nav ul li a {
display: block;
color: #1b1b1b;
text-align: center;
text-decoration: none;
transition: 0.5s;
font-size: 1.5em;
padding: 5px;
}
/* Change background color of links on hover */
nav ul li.padnav a:hover {
-webkit-transition: 0.2s; /* Safari */
transition: 0.2s;
border-bottom: 5px solid #2098D1;
}
.active{
-webkit-transition: 0.1s; /* Safari */
transition: 0.1s;;
border-bottom: 5px solid #2098D1;
}
.hide{
display: none;
width: 0px;
height: 0px;
}
nav{
position: fixed;
}
/* Hide the list item that contains the link that should open and close the topnav on small screens */
ul.topnav li.icon {
display: none;
}
/* When the screen is less than 680 (changed to 770 to accomodate) pixels wide, hide all list items, except for the first one ("Home"). Show the list item that contains the link to open and close the topnav (li.icon) */
@media screen and (max-width:767px) {
ul.topnav li:not(:first-child) {
display: none;
}
ul.topnav li:nth-child(1){
display: inline-block !important;
width: auto !important;
height: auto !important;
}
ul.topnav li.icon {
float: right;
display: inline-block;
width: 60px;
}
ul.topnav li{
padding: 0px !important;
}
ul.topnav a{
margin-top: 25px !important;
margin-right: 25px !important;
padding: 0px !important;
}
li img {
display: none;
}
.topnav{
width: 100% !important;
}
#navhit{
height: 50px;
width: 80px;
float: right;
display: inline-block;
margin-top: -8px;
}
li.padnav{
padding: 0px !important;
margin-top: 0px !important;
}
ul.topnav li.padnav a:hover {
border: none !important;
}
#navwrapper{
padding-bottom: 20px;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens */
@media screen and (max-width:767px) {
ul.topnav.responsive {position: relative;}
ul.topnav.responsive li.icon {
position: absolute;
right: 0;
top: 0;
}
ul.topnav.responsive li {
float: none;
display: inline;
}
ul.topnav.responsive li a {
display: block;
text-align: left;
}
}
/*sections*/
section {
width: 100%;
padding: 0 7%;
display: table;
margin: 0;
max-width: none;
height: 100vh;
}
section.landing{
background-color: #f39c12;
}
section.about{
background-color: #9b59b6;
}
section.project{
background-color: #2ecc71;
}
section.blog{
background-color: #95a5a6;
}
section.contact{
background-color: #f1c40f;
}
.landing{
height: 95vh;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="navwrapper">
\t <nav class="navbar bebas-reg container">
\t \t <ul class="topnav" id="myTopnav">
\t \t \t <li class="padnav"><a href="about.html" class="about-marker active">About</a></li>
\t \t \t <li class="padnav"><a href="projects.html" class="proj-marker">Projects</a></li>
\t \t \t <li class="logo"><img src="img/logo-black.png"></img></li>
\t \t \t <li class="padnav"><a href="contact" class="contact-marker">Contact</a></li>
\t \t \t <li class="padnav"><a href="blog" class="blog-marker">Blog</a></li>
\t \t </ul>
\t </nav>
</div>
<section class="landing">
\t <h1> landing </h1>
</section>
<section class="about">
\t <h1> about </h1>
</section>
<section class="proj">
\t <h1> proj </h1>
</section>
<section class="contact">
\t <h1> contact </h1>
</section>
<section class="blog">
\t <h1> blog </h1>
</section>
1〜それはスニペットにうまく表示さdoesntのが、私は自分のサーバー上でそれを試してみましたが、正常に動作しますが、 codepenで明白なエラーが1つ修正されました.20以上がポップアップしました.3)ブラウザの開発ツールコンソールでエラーが発生しましたか?4)**「スクロールスパイのような効果」**手段。そして5) '誰かがこのクエリコードを修正できましたか? 'という質問に' query code'を投稿し、コードで修正したいものを説明することができます –
"scrollspy"がうまく動作します。 – yuriy636