为什么我的网站页面主题位于导航栏(引导程序)后面?

发布于 2025-01-10 09:09:54 字数 325 浏览 0 评论 0原文

我尝试查看当我单击导航栏时我想查看该主题,但它在导航栏下显示该主题。我尝试给予保证金,但没有效果。有人帮助我如何解决这个问题。

网站显示类似

但我想看到这样的

there is code: https://codepen.io/rero34/pen/mdqGyVo

I try to see when I click navbar then I want to see the topic, but it is showing the topic under navbar. I try to give margin, but it doesn't work. Is someone help me with how can I solve this problem.

Web site showing like that

But I want to see like that

there is code: https://codepen.io/rero34/pen/mdqGyVo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浪推晚风 2025-01-17 09:09:54

所以你正在使用 Bootstrap,这很棒。但我的第一印象是你有太多的手动样式,尤其是使用 CSS 框架。无需过度解释,您的锚点未从该部分的顶部开始的主要原因是因为您的 id 是从跨度开始的,这不是该部分的开头。您应该将 id 放在各个部分本身上。

然后,下一个问题来自于在章节上使用填充以及标题上过多的边距。在不仔细检查和清理所有这些内容的情况下,让我们看看解决方法。

scroll-margin 用于调整元素的捕捉区域(定义元素将捕捉到的位置的框)。

我添加了一些 scroll-margin-top 每个部分。我发现大约 5.5em 是您的情况的最佳位置。

您的代码对于堆栈片段来说字符太多,因此请查看 CodePen

So you are using Bootstrap which is great. But my first impression was you have too many manual styles going on, especially for using a CSS framework. Without over-explaining it, the main reason your anchors aren't starting at the top of the section is because your id's are starting at the span, which is not the start of the section. You should put the id's on the sections themselves.

Then, the next issue comes from the use of padding on your sections and excessive margins on headings. Without going through and cleaning all of those up, let's look at ways around it.

scroll-margin is used to adjust an element’s snap area (the box that defines where the element will be snapped to).

I added some scroll-margin-top on each section. I found that roughly 5.5em is the sweet spot in your case.

Your code has too many characters for a stack snippet, so take a look in the CodePen.

吃素的狼 2025-01-17 09:09:54

我认为这是使用固定导航栏的自然 z-index 副作用。看看将 margin-top 添加到紧跟在导航栏后面的元素是否有区别。这似乎是 div id="myCarousel"。您添加的边距应与导航栏的高度相同“px”。

I think it is a natural z-index side-effect of using a fixed navbar. See if it makes a difference to add margin-top to the element immediately following the navbar. That seems to be div id="myCarousel". The margin you add should be the same 'px' tall as your navbar.

乖不如嘢 2025-01-17 09:09:54

因为在_robot.css文件中设置了margin-top: 0;。对于第三级标题标签。

您可以使用 H3 标记的自定义样式来克服此默认设置,以设置适当的 margin-top: 100px !important;。根据您的需要定制它,我将 100px 作为随机值。

    h3{
       font-weight: 700;
       margin-bottom: 50px;    
       margin-top: 100px !important;
    }

编辑
我发现您多次定义了 h3margin-top 。可能是有冲突导致的。您的风格的下一次出现是在稍后的时间

    .services h3{
      margin-top: 80px;
    }

Because there is set the margin-top: 0; in the _robot.css file. for the 3rd-level header tag.

You can overcome this default settings with your custom style of the H3 tag to set the appropriate margin-top: 100px !important;. Customize it to your needs, I take the 100px as random value.

    h3{
       font-weight: 700;
       margin-bottom: 50px;    
       margin-top: 100px !important;
    }

Edit
I found you have the margin-top for h3 defined several times. There might be the conflict which cause it. Next occurenc in your style is later in

    .services h3{
      margin-top: 80px;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文