HTML / CSS Панель навигации не отвечает правильно - PullRequest
1 голос
/ 18 июня 2020

Я новичок в более активном веб-дизайне, если это можно так назвать! Похоже, у меня проблемы с панелью навигации. Кажется, он работает со всеми моими разделами, кроме одного, раздела "О".

Я включил весь код CSS, так как думаю, что здесь проблема.

$(document).ready(function () {
    $('.menu-toggler').on('click', function () {
        $(this).toggleClass('open');
        $('.top-nav').toggleClass('open');
    });

    $('.top-nav .nav-link').on('click', function () {
      $('.menu-toggler').removeClass('open');
      $('.top-nav').removeClass('open');
    });

    $('nav a[href*="#"]').not("#blog").on("click", function () {
      $("#js-menu").toggleClass('active');
   $("html, body").animate({
  scrollTop: $($(this).attr("href")).offset().top
   }, 500);
    });

    $("#up").on("click", function () {
      $("html, body").animate({
        scrollTop: 0
         }, 1000); 
    });
  });
/*Start global*/
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: #e9e9e9;
}

body{
    width: 100%;
    height: 100%;
    background: url("images/sitebg.jpg") no-repeat center fixed;
    background-size: cover;
    text-align: center;
}
section{
    padding: 6rem 0;
}
a{
    text-decoration: none;
    color: #e9e9e9;
}

p{
    font-weight: 300;
    font-size: 1.8rem;
}

img{
    width: 100%;
}
/*End global*/

/*Start reusable*/
.container{
    width: 90%;
    max-width: 120rem;
    height: 100%;
    margin: 0 auto;
    position: relative;
    padding: .3rem;
}

.section-heading{
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-heading h1{
    font-size: 3.5rem;
    color: black;
    text-transform: uppercase;
    font-weight: 300;
    position: relative;
    margin-bottom: 1rem;
}

.section-heading h1::before,
.section-heading h1::after{
    content: '';
    position: absolute;
    bottom: -5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.75);
}

.section-heading h1::before{
    width: 10rem;
    height: 3px;
    border-radius: 0.8rem;
    bottom: -4.5rem;
}


.section-heading h6{
    font-size: 1.6rem;
    font-weight: 300;
}

.has-margin-right{
    margin-right: 5rem;
}

/*End reusable*/

/*Start header*/
header{
    width: 100%;
    height: 100%;
}

.top-nav{
    width: 100%;
    height: 100vh;
    position: fixed;
    top: -100vh;
    z-index: 50;
    background-color: #16162d;
    border-bottom-right-radius: 100%;
    border-bottom-left-radius: 100%;
    transition: all 650ms cubic-bezier(1, 0, 0, 1);
}

.nav-list{
    list-style: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

li{
    margin: 0.2rem;
}
@font-face {
    font-family: 'The Historia Demo';
    src: url('/fonts/the_historia_demo-webfont.woff2') format('woff2'),
         url('fonts/the_historia_demo-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
  }
  
.nav-link{
font-family:"The Historia Demo", sans-serif;
    font-size: 5rem;
    padding: 1rem;
}

.nav-link:hover,
.nav-link:focus{
    background: linear-gradient(to top, #ffe838, #fd57bf );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-nav.open{
    top: 0;
    border-radius: initial;
}

.menu-toggler{
    position: absolute;
    top: 5rem;
    right: 5rem;
    width: 5rem;
    height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    z-index: 1500;
    transition: transform 650ms ease-out;
}

.menu-toggler.open{
    transform: rotate(-45deg);
}

.bar{
    background: linear-gradient(to right, #ffe838, #fd57bf);
    width: 100%;
    height: 4px;
    border-radius: .8rem;
}

.bar.half{
    width: 50%;
}

.bar.start{
    transform-origin: right;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.start{
    transform: rotate(-450deg) translateX(.8rem);
}

.bar.end{
    align-self: flex-end;
    transform-origin: left;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.end{
    transform: rotate(-450deg) translateX(-.8rem);
}

.landing-text{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    z-index: 1;
}

.landing-text h1{
    font-size: 15rem;
    font-weight: 500;
    font-family: "The Historia Demo", sans-serif;
    background: linear-gradient(to top, #ffe838 30%, #fd57bf );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 1rem;
    user-select: none;
    line-height: 1.1;
}

.landing-text h6{
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 0.4rem;
}

.landingbtn {
    margin: 1rem auto;
    background-color:#16162d;
    height: 3rem;
    width: 15rem;
    cursor: pointer;
    transition: 0.2s ease-in;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: capitalize;
    opacity: 0.5;
  
}
  
.landingbtn p {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 2rem;
}
  
.landingbtn:hover {
    transform: scale(1.05);
    background-color: #221e3f;
}
/*End header*/

/*Start about*/
.about .container{
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 60rem;
}

.about-heading{
    text-align: center;
    text-transform: uppercase;
    line-height: 0;
    margin-bottom: 6rem;
}

.about-heading h1{
    font-size: 10rem;
    opacity: .3;
}


.about-heading h6{
    font-size: 2rem;
    font-weight: 300;
}

.profile-img{
    flex: 1;
    margin-right: 5rem;
}

.about-details{
    flex: 1;
}

.social-media{
    margin-top: 5rem;
}

.social-media i{
    font-size: 5rem;
    transition: color 650ms;
    padding: 1rem;
}

.fa-linkedin:hover{
    color: #0e76a8;
}

.fa-github:hover{
    color: #211F1F;
}

.fa-soundcloud:hover{
    color: #ff7700;
}

/*End about*/

/*Start services*/
.my-skills{
    margin-top: 3.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    grid-gap: 2.5rem;
    text-align: center;

}
image

Любое понимание было бы очень признательно !!

Ответы [ 2 ]

1 голос
/ 18 июня 2020

У вас есть .container раздела about с margin-top: 60rem;, так что технически точка привязки работает , но ее позиция находится в верхней части документа: (

Чтобы избежать этого, вы можете изменить position:absolute из .landing-text на значение по умолчанию, а в разделе about он будет go вниз .landing-text без margin-top, чтобы имитировать его положение. Надеюсь, это поможет вы.

Вот код: (Запустите фрагмент кода до полной страницы, чтобы увидеть решение)

$(document).ready(function () {
    $('.menu-toggler').on('click', function () {
        $(this).toggleClass('open');
        $('.top-nav').toggleClass('open');
    });

    $('.top-nav .nav-link').on('click', function () {
      $('.menu-toggler').removeClass('open');
      $('.top-nav').removeClass('open');
    });

    $('nav a[href*="#"]').not("#blog").on("click", function () {
      $("#js-menu").toggleClass('active');
   $("html, body").animate({
  scrollTop: $($(this).attr("href")).offset().top
   }, 500);
    });

    $("#up").on("click", function () {
      $("html, body").animate({
        scrollTop: 0
         }, 1000); 
    });
  });
/*Start global*/
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: #e9e9e9;
}

body{
    width: 100%;
    height: 100%;
    background: url("images/sitebg.jpg") no-repeat center fixed;
    background-size: cover;
    text-align: center;
}
section{
    padding: 6rem 0;
}
a{
    text-decoration: none;
    color: #e9e9e9;
}

p{
    font-weight: 300;
    font-size: 1.8rem;
}

img{
    width: 100%;
}
/*End global*/

/*Start reusable*/
.container{
    width: 90%;
    max-width: 120rem;
    height: 100%;
    margin: 0 auto;
    position: relative;
    padding: .3rem;
}

.section-heading{
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-heading h1{
    font-size: 3.5rem;
    color: black;
    text-transform: uppercase;
    font-weight: 300;
    position: relative;
    margin-bottom: 1rem;
}

.section-heading h1::before,
.section-heading h1::after{
    content: '';
    position: absolute;
    bottom: -5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.75);
}

.section-heading h1::before{
    width: 10rem;
    height: 3px;
    border-radius: 0.8rem;
    bottom: -4.5rem;
}


.section-heading h6{
    font-size: 1.6rem;
    font-weight: 300;
}

.has-margin-right{
    margin-right: 5rem;
}

/*End reusable*/

/*Start header*/
header{
    width: 100%;
    height: 100%;
}

.top-nav{
    width: 100%;
    height: 100vh;
    position: fixed;
    top: -100vh;
    z-index: 50;
    background-color: #16162d;
    border-bottom-right-radius: 100%;
    border-bottom-left-radius: 100%;
    transition: all 650ms cubic-bezier(1, 0, 0, 1);
}

.nav-list{
    list-style: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

li{
    margin: 0.2rem;
}
@font-face {
    font-family: 'The Historia Demo';
    src: url('/fonts/the_historia_demo-webfont.woff2') format('woff2'),
         url('fonts/the_historia_demo-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
  }
  
.nav-link{
font-family:"The Historia Demo", sans-serif;
    font-size: 5rem;
    padding: 1rem;
}

.nav-link:hover,
.nav-link:focus{
    background: linear-gradient(to top, #ffe838, #fd57bf );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-nav.open{
    top: 0;
    border-radius: initial;
}

.menu-toggler{
    position: absolute;
    top: 5rem;
    right: 5rem;
    width: 5rem;
    height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    z-index: 1500;
    transition: transform 650ms ease-out;
}

.menu-toggler.open{
    transform: rotate(-45deg);
}

.bar{
    background: linear-gradient(to right, #ffe838, #fd57bf);
    width: 100%;
    height: 4px;
    border-radius: .8rem;
}

.bar.half{
    width: 50%;
}

.bar.start{
    transform-origin: right;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.start{
    transform: rotate(-450deg) translateX(.8rem);
}

.bar.end{
    align-self: flex-end;
    transform-origin: left;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.end{
    transform: rotate(-450deg) translateX(-.8rem);
}

.landing-text{
    width: 100%;
}

.landing-text h1{
    font-size: 15rem;
    font-weight: 500;
    font-family: "The Historia Demo", sans-serif;
    background: linear-gradient(to top, #ffe838 30%, #fd57bf );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 1rem;
    user-select: none;
    line-height: 1.1;
}

.landing-text h6{
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 0.4rem;
}

.landingbtn {
    margin: 1rem auto;
    background-color:#16162d;
    height: 3rem;
    width: 15rem;
    cursor: pointer;
    transition: 0.2s ease-in;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: capitalize;
    opacity: 0.5;
  
}
  
.landingbtn p {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 2rem;
}
  
.landingbtn:hover {
    transform: scale(1.05);
    background-color: #221e3f;
}
/*End header*/

/*Start about*/
.about .container{
    display: flex;
    align-items: center;
    justify-content: center;
}

.about-heading{
    text-align: center;
    text-transform: uppercase;
    line-height: 0;
    margin-bottom: 6rem;
}

.about-heading h1{
    font-size: 10rem;
    opacity: .3;
}


.about-heading h6{
    font-size: 2rem;
    font-weight: 300;
}

.profile-img{
    flex: 1;
    margin-right: 5rem;
}

.about-details{
    flex: 1;
}

.social-media{
    margin-top: 5rem;
}

.social-media i{
    font-size: 5rem;
    transition: color 650ms;
    padding: 1rem;
}

.fa-linkedin:hover{
    color: #0e76a8;
}

.fa-github:hover{
    color: #211F1F;
}

.fa-soundcloud:hover{
    color: #ff7700;
}

/*End about*/

/*Start services*/
.my-skills{
    margin-top: 3.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    grid-gap: 2.5rem;
    text-align: center;

}
image
0 голосов
/ 18 июня 2020

    
    $(document).ready(function () {
    $('.menu-toggler').on('click', function () {
        $(this).toggleClass('open');
        $('.top-nav').toggleClass('open');
    });

    $('.top-nav .nav-link').on('click', function () {
      $('.menu-toggler').removeClass('open');
      $('.top-nav').removeClass('open');
    });

    $('nav a[href*="#"]').not("#blog").on("click", function () {
      $("#js-menu").toggleClass('active');
   $("html, body").animate({
  scrollTop: $($(this).attr("href")).offset().top
   }, 500);
    });

    $("#up").on("click", function () {
      $("html, body").animate({
        scrollTop: 0
         }, 1000); 
    });
  });
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue';
    color: #e9e9e9;
}

body {
    text-align: center;
}

section {
    padding: 6rem 0;
}

a {
    text-decoration: none;
    color: #e9e9e9;
}

p {
    font-weight: 300;
    font-size: 1.8rem;
}

img {
    width: 100%;
}


/*End global*/


/*Start reusable*/

.container {
    width: 90%;
    max-width: 120rem;
    height: 100%;
    margin: 0 auto;
    position: relative;
    padding: .3rem;
}

.section-heading {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-heading h1 {
    font-size: 3.5rem;
    color: black;
    text-transform: uppercase;
    font-weight: 300;
    position: relative;
    margin-bottom: 1rem;
}

.section-heading h1::before,
.section-heading h1::after {
    content: '';
    position: absolute;
    bottom: -5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.75);
}

.section-heading h1::before {
    width: 10rem;
    height: 3px;
    border-radius: 0.8rem;
    bottom: -4.5rem;
}

.section-heading h6 {
    font-size: 1.6rem;
    font-weight: 300;
}

.has-margin-right {
    margin-right: 5rem;
}


/*End reusable*/


/*Start header*/

header {
    width: 100%;
    height: 100%;
}

.top-nav {
    width: 100%;
    height: 100vh;
    position: fixed;
    top: -100vh;
    z-index: 50;
    background-color: #16162d;
    border-bottom-right-radius: 100%;
    border-bottom-left-radius: 100%;
    transition: all 650ms cubic-bezier(1, 0, 0, 1);
}

.nav-list {
    list-style: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

li {
    margin: 0.2rem;
}

@font-face {
    font-family: 'The Historia Demo';
    src: url('/fonts/the_historia_demo-webfont.woff2') format('woff2'), url('fonts/the_historia_demo-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

.nav-link {
    font-family: "The Historia Demo", sans-serif;
    font-size: 2rem;
    padding: 1rem;
}

.nav-link:hover,
.nav-link:focus {
    background: linear-gradient(to top, #ffe838, #fd57bf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-nav.open {
    top: 0;
    border-radius: initial;
}

.menu-toggler {
    position: absolute;
    top: 5rem;
    right: 5rem;
    width: 5rem;
    height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    z-index: 1500;
    transition: transform 650ms ease-out;
}

.menu-toggler.open {
    transform: rotate(-45deg);
}

.bar {
    background: linear-gradient(to right, #ffe838, #fd57bf);
    width: 100%;
    height: 4px;
    border-radius: .8rem;
}

.bar.half {
    width: 50%;
}

.bar.start {
    transform-origin: right;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.start {
    transform: rotate(-450deg) translateX(.8rem);
}

.bar.end {
    align-self: flex-end;
    transform-origin: left;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.057, 0.57);
}

.open .bar.end {
    transform: rotate(-450deg) translateX(-.8rem);
}

.landing-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    z-index: 1;
}

.landing-text h1 {
    font-size: 5rem;
    font-weight: 500;
    font-family: "The Historia Demo", sans-serif;
    background: linear-gradient(to top, #ffe838 30%, #fd57bf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 1rem;
    user-select: none;
    line-height: 1.1;
}

.landing-text h6 {
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 0.4rem;
}

.landingbtn {
    margin: 1rem auto;
    background-color: #16162d;
    height: 3rem;
    width: 15rem;
    cursor: pointer;
    transition: 0.2s ease-in;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    text-transform: capitalize;
    opacity: 0.5;
}

.landingbtn p {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue';
    font-size: 2rem;
}

.landingbtn:hover {
    transform: scale(1.05);
    background-color: #221e3f;
}


/*End header*/


/*Start about*/

.about .container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 60rem;
}

.about-heading {
    text-align: center;
    text-transform: uppercase;
    line-height: 0;
    margin-bottom: 6rem;
}

.about-heading h1 {
    font-size: 10rem;
    opacity: .3;
}

.about-heading h6 {
    font-size: 2rem;
    font-weight: 300;
}

.profile-img {
    flex: 1;
    margin-right: 5rem;
}

.about-details {
    flex: 1;
}

.social-media {
    margin-top: 5rem;
}

.social-media i {
    font-size: 5rem;
    transition: color 650ms;
    padding: 1rem;
}

.fa-linkedin:hover {
    color: #0e76a8;
}

.fa-github:hover {
    color: #211F1F;
}

.fa-soundcloud:hover {
    color: #ff7700;
}


/*End about*/


/*Start services*/

.my-skills {
    margin-top: 3.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    grid-gap: 2.5rem;
    text-align: center;
}

@media only screen and (max-width: 600px) {
   .nav-list {
        display: block;
   }

   .nav-list{
       margin-top: 48%;
           margin-left: -7%;
   }

   .nav-list li{
        margin-top: 10px;
   }
   .menu-toggler {    width: 4rem;
    height: 3rem;right: 4rem;}

    .landing-text h1 {
    font-size: 3rem; margin-bottom: 20px;}

    .landingbtn {    width: 10rem;}

    .landingbtn p{font-size: 24px;}

    .about-details{margin-left: -27%;}

    .about-heading h1 {
    font-size: 6rem;}

}
image
...