无法在 HTML、CSS 中正确定位某个部分
P粉481035232
P粉481035232 2023-09-10 10:29:17
[CSS3讨论组]

我正在创建一个投资组合网站,我想要在“关于”部分下面有一个“爱好”部分。当我第一次制作爱好部分时,它出现在 about 部分上方,尽管我已将其编码在 HTML 中的 about 部分下方。现在,当我尝试使用 DevTools 将其放置在 about 部分下方时,它隐藏在 about 部分下方。我们将不胜感激您的帮助。

const observer = new IntersectionObserver((entries) => {
  entries.forEach((entry) => {
    console.log(entry)
    if (entry.isIntersecting) {
      entry.target.classList.add('show');
    } else {
      entry.target.classList.remove("show");
    }
  })
})

const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((el) => observer.observe(el));
/* width */
::-webkit-scrollbar {
  width: 10px;
}

/* Track */
::-webkit-scrollbar-track {
  background: #f1f1f1;
}

/* Handle */
::-webkit-scrollbar-thumb {
  background: rgb(0, 118, 214);
}


* {
  margin: 0;
  padding: 0;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

html {
  scroll-behavior: smooth;
}

#hero {
  background-color: darkgray;
  height: 100vh;
}

#hey {
  position: absolute;
  top: 228px;
  left: 46vw;
}

#name {
  position: absolute;
  top: 39vh;
  left: 39vw;
}

#line_1 {
  position: absolute;
  top: 50vh;
  left: 23vw;
}

#line_2 {
  position: absolute;
  top: 50vh;
  right: 21vw;
}

nav {
  position: fixed;
  top: -50px;
  left: 20.7vw;
  width: 100%;
  background-image: url("navbar.png");
  background-repeat: no-repeat;
  transition: top 0.2s ease-in-out;
  font-family: 'Playfair Display', serif;
}

nav ul {
  margin: 0;
  padding: 0;
  position: relative;
  right: 313px;
  list-style: none;
  text-align: center;
  font-size: larger;
}

nav li {
  display: inline-block;
  margin: 10px;
  margin-right: 25px;
}

nav a {
  display: block;
  padding: 10px;
  color: #fff;
  text-decoration: none;
}


nav:hover {
  top: 0;
}

.hover-underline-animation {
  display: inline-block;
  position: relative;
  color: #ffffff;
}

.hover-underline-animation:after {
  content: '';
  position: absolute;
  width: 100%;
  transform: scaleX(0);
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #ffffff;
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}

.hover-underline-animation:hover:after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

#about {
  position: absolute;
  top: 111vh;
  left: 45vw;
  font-family: 'Playfair Display';
  width: 29vw;
}

#about h1 {
  font-size: xx-large;

}

#about h2 {
  font-size: large;
  position: relative;
  left: -13px;
  top: 48px;
}

#profile_pic {
  position: relative;
  bottom: 161px;
  right: 305px;
}

#india {
  position: relative;
  right: 276px;
  bottom: 163px;
  height: 56px;
}

.hidden {
  opacity: 0;
  transform: translateX(-100%);
  transition: all 1s;
}

.show {
  opacity: 1;
  filter: blur(0);
  transform: translateX(0);
}

#blur_bg {
  animation: fadeInAnimation ease 3s;
  position: relative;
  bottom: 76vh;
  left: 28vw;
}

#blur_bg2 {
  animation: fadeInAnimation ease 3s;
  position: relative;
  bottom: 162vh;
  left: -58vw;
}

@keyframes fadeInAnimation {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

#hr {
  position: absolute;
  bottom: 145vh;
  right: -1vw;
  width: 50vw;
}

#hobbies {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}


  
    
    
    
    I'm Shardul Bhatkar
    
    
    
    
    
    
  
  
    
    

About Me

My Hobbies

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Fugit vel sit quasi quas. Unde laboriosam est eveniet modi culpa velit.

P粉481035232
P粉481035232

全部回复(1)
P粉421119778

您能否告诉我以下 CSS 是否有效?如果不是,您在以下 CSS 中发现了什么问题?

/* width */
    ::-webkit-scrollbar {
        width: 10px;
    }

    /* Track */
    ::-webkit-scrollbar-track {
        background: #f1f1f1;
    }

    /* Handle */
    ::-webkit-scrollbar-thumb {
        background: rgb(0, 118, 214);
    }


    * {
        margin: 0;
        padding: 0;
    }

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    html {
        scroll-behavior: smooth;
    }

    #hero {
        background-color: darkgray;
        height: 100vh;
    }

    #hey {
        /* position: absolute; */
        top: 228px;
        left: 46vw;
    }

    #name {
        /* position: absolute; */
        top: 39vh;
        left: 39vw;
    }

    #line_1 {
        /* position: absolute; */
        top: 50vh;
        left: 23vw;
    }

    #line_2 {
        /* position: absolute; */
        top: 50vh;
        right: 21vw;
    }

    nav {
        position: fixed;
        top: -50px;
        left: 20.7vw;
        width: 100%;
        background-image: url("navbar.png");
        background-repeat: no-repeat;
        transition: top 0.2s ease-in-out;
        font-family: 'Playfair Display', serif;
    }

    nav ul {
        margin: 0;
        padding: 0;
        position: relative;
        right: 313px;
        list-style: none;
        text-align: center;
        font-size: larger;
    }

    nav li {
        display: inline-block;
        margin: 10px;
        margin-right: 25px;
    }

    nav a {
        display: block;
        padding: 10px;
        color: #fff;
        text-decoration: none;
    }


    nav:hover {
        top: 0;
    }

    .hover-underline-animation {
        display: inline-block;
        position: relative;
        color: #ffffff;
    }

    .hover-underline-animation:after {
        content: '';
        position: absolute;
        width: 100%;
        transform: scaleX(0);
        height: 2px;
        bottom: 0;
        left: 0;
        background-color: #ffffff;
        transform-origin: bottom right;
        transition: transform 0.25s ease-out;
    }

    .hover-underline-animation:hover:after {
        transform: scaleX(1);
        transform-origin: bottom left;
    }

    #about {
        /* position: absolute; */
        /* top: 111vh;
        left: 45vw; */
        margin: auto;
        font-family: 'Playfair Display';
        width: 29vw;
    }

    #about h1 {
        font-size: xx-large;

    }

    #about h2 {
        font-size: large;
        /* position: relative; */
        left: -13px;
        top: 48px;
    }

    #profile_pic {
        /* position: relative; */
        bottom: 161px;
        right: 305px;
    }

    #india {
        /* position: relative; */
        right: 276px;
        bottom: 163px;
        height: 56px;
    }

    .hidden {
        opacity: 0;
        transform: translateX(-100%);
        transition: all 1s;
    }

    .show {
        opacity: 1;
        filter: blur(0);
        transform: translateX(0);
    }

    #blur_bg {
        animation: fadeInAnimation ease 3s;
        /* position: relative; */
        bottom: 76vh;
        left: 28vw;
    }

    #blur_bg2 {
        animation: fadeInAnimation ease 3s;
        /* position: relative; */
        bottom: 162vh;
        left: -58vw;
    }

    @keyframes fadeInAnimation {
        0% {
            opacity: 0;
        }

        100% {
            opacity: 1;
        }
    }

    #hr {
        /* position: absolute; */
        bottom: 145vh;
        right: -1vw;
        width: 50vw;
    }

    #hobbies {
        /* position: relative; */
        display: flex;
        flex-direction: column;
        align-items: center;
    }
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号