Bootstrap 3奇怪的粘贴问题(Bootstrap 3 weird affix issue on chrome)

编程入门 行业动态 更新时间:2024-10-14 18:20:51
Bootstrap 3奇怪的粘贴问题(Bootstrap 3 weird affix issue on chrome)

所以我试图使用引导附加功能,但它奇怪。 当您尝试向下滚动标题部分时,它会自动转到顶部。 当屏幕宽度低于1100px时会发生这种情况。 当您使用滚动条进行滚动时,它也仅限于Chrome浏览器。 我有一个bootply安装程序来演示发生了什么。 那么,任何人都可以帮我弄清楚发生了什么?

观看此视频可能会有所帮助。

CSS:

header { height: 365px; background: url("http://i.imgur.com/wU2YhOJ.png"); background-color: #262626; background-size: cover; background-position: center; } header h1{ font-family: Montserrat, sans-serif !important; font-size: 5.5em; color: white; word-break: normal; padding-top: 115px; } body h1 { font-family: 'Lato', sans-serif; line-height: 72px; } body, footer { font-family: 'Open Sans', sans-serif !important; } body p { line-height: 28px; } footer { background-color: #262626; } .fixed { position: fixed; } /* sidebar */ .bs-docs-sidebar { padding-left: 20px; margin-top: 60px; margin-bottom: 20px; } /* all links */ .bs-docs-sidebar .nav>li>a { color: #999; border-left: 2px solid transparent; padding: 4px 20px; font-size: 13px; font-weight: 400; } /* nested links */ .bs-docs-sidebar .nav .nav>li>a { padding-top: 1px; padding-bottom: 1px; padding-left: 30px; font-size: 12px; } /* active & hover links */ .bs-docs-sidebar .nav>.active>a, .bs-docs-sidebar .nav>li>a:hover, .bs-docs-sidebar .nav>li>a:focus { color: #262626; text-decoration: none; background-color: transparent; border-left-color: #262626; } /* all active links */ .bs-docs-sidebar .nav>.active>a, .bs-docs-sidebar .nav>.active:hover>a, .bs-docs-sidebar .nav>.active:focus>a { font-weight: 700; } /* nested active links */ .bs-docs-sidebar .nav .nav>.active>a, .bs-docs-sidebar .nav .nav>.active:hover>a, .bs-docs-sidebar .nav .nav>.active:focus>a { font-weight: 500; } /* hide inactive nested list */ .bs-docs-sidebar .nav ul.nav { display: none; } /* show active nested list */ .bs-docs-sidebar .nav>.active>ul.nav { display: block; } /* special back to top styling */ .back-to-top:hover, .back-to-top:focus{ border-left-color: transparent !important; }

HTML:

<div class="col-sm-2" id="body-right"> <nav class="col-xs-3 bs-docs-sidebar"> <ul id="sidebar" class="nav nav-stacked fixed"> <li> <a href="#GroupA">Getting Started</a> <ul class="nav nav-stacked"> <li><a href="#GroupASub1">Sub-Group 1</a></li> <li><a href="#GroupASub2">Sub-Group 2</a></li> </ul> </li> <li> <a href="#GroupB">Font Awesome</a> <ul class="nav nav-stacked"> <li><a href="#GroupBSub1">Sub-Group 1</a></li> <li><a href="#GroupBSub2">Sub-Group 2</a></li> </ul> </li> <li> <a href="#GroupC">Bootstrap</a> <ul class="nav nav-stacked"> <li><a href="#GroupCSub1">Sub-Group 1</a></li> <li><a href="#GroupCSub2">Sub-Group 2</a></li> </ul> </li> <li><span>&nbsp</span></li> <li> <a class="back-to-top" href="#header">Back to top</a> </li> </ul> </nav> </div>

So I am trying to use the bootstrap affix feature but it acts weird. When you try to scroll down past the header section it automatically goes to the top. This happens when the screen width is below 1100px. Also its only on Chrome when you scroll with the scroll bar. I have a bootply setup to demonstrate whats happening. So can anybody please help me figure out whats going on?

Watching this video might help.

CSS:

header { height: 365px; background: url("http://i.imgur.com/wU2YhOJ.png"); background-color: #262626; background-size: cover; background-position: center; } header h1{ font-family: Montserrat, sans-serif !important; font-size: 5.5em; color: white; word-break: normal; padding-top: 115px; } body h1 { font-family: 'Lato', sans-serif; line-height: 72px; } body, footer { font-family: 'Open Sans', sans-serif !important; } body p { line-height: 28px; } footer { background-color: #262626; } .fixed { position: fixed; } /* sidebar */ .bs-docs-sidebar { padding-left: 20px; margin-top: 60px; margin-bottom: 20px; } /* all links */ .bs-docs-sidebar .nav>li>a { color: #999; border-left: 2px solid transparent; padding: 4px 20px; font-size: 13px; font-weight: 400; } /* nested links */ .bs-docs-sidebar .nav .nav>li>a { padding-top: 1px; padding-bottom: 1px; padding-left: 30px; font-size: 12px; } /* active & hover links */ .bs-docs-sidebar .nav>.active>a, .bs-docs-sidebar .nav>li>a:hover, .bs-docs-sidebar .nav>li>a:focus { color: #262626; text-decoration: none; background-color: transparent; border-left-color: #262626; } /* all active links */ .bs-docs-sidebar .nav>.active>a, .bs-docs-sidebar .nav>.active:hover>a, .bs-docs-sidebar .nav>.active:focus>a { font-weight: 700; } /* nested active links */ .bs-docs-sidebar .nav .nav>.active>a, .bs-docs-sidebar .nav .nav>.active:hover>a, .bs-docs-sidebar .nav .nav>.active:focus>a { font-weight: 500; } /* hide inactive nested list */ .bs-docs-sidebar .nav ul.nav { display: none; } /* show active nested list */ .bs-docs-sidebar .nav>.active>ul.nav { display: block; } /* special back to top styling */ .back-to-top:hover, .back-to-top:focus{ border-left-color: transparent !important; }

HTML:

<div class="col-sm-2" id="body-right"> <nav class="col-xs-3 bs-docs-sidebar"> <ul id="sidebar" class="nav nav-stacked fixed"> <li> <a href="#GroupA">Getting Started</a> <ul class="nav nav-stacked"> <li><a href="#GroupASub1">Sub-Group 1</a></li> <li><a href="#GroupASub2">Sub-Group 2</a></li> </ul> </li> <li> <a href="#GroupB">Font Awesome</a> <ul class="nav nav-stacked"> <li><a href="#GroupBSub1">Sub-Group 1</a></li> <li><a href="#GroupBSub2">Sub-Group 2</a></li> </ul> </li> <li> <a href="#GroupC">Bootstrap</a> <ul class="nav nav-stacked"> <li><a href="#GroupCSub1">Sub-Group 1</a></li> <li><a href="#GroupCSub2">Sub-Group 2</a></li> </ul> </li> <li><span>&nbsp</span></li> <li> <a class="back-to-top" href="#header">Back to top</a> </li> </ul> </nav> </div>

最满意答案

我不知道这是怎么发生的......但在玩了一段时间后, 我有一个修复。

我认为是什么导致它是box-sizing:border-box在bootstrap.min.css (line 7) 。

要么改变它,要么将其重写为box-sizing:content-box似乎可以解决这个问题。

如果您有自定义的css文件,请使用以下类来覆盖引导程序。

* { box-sizing:content-box; }

希望这可以帮助

I don't know how this happens.. but after playing with the bootply for some time. I have a fix.

I think what causes it is the box-sizing:border-box at bootstrap.min.css (line 7).

Either changing that, or overriding it to box-sizing:content-box seem to fix this issue.

If you have a custom css file, use the following class to override bootstrap.

* { box-sizing:content-box; }

Hope This Helps

更多推荐

本文发布于:2023-08-01 13:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:奇怪   weird   Bootstrap   chrome   issue

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!